Exemple #1
0
	def __init__(self, in_dataset_file,  tag_key = None, tag_values_str = None, query = None, nick_regex = None):
		self.in_dataset_file = in_dataset_file
		self.dataset = datasetsHelperTwopz(in_dataset_file)
		self.orginal = datasetsHelperTwopz(in_dataset_file) #Just a copy to compare
		self.tag_key = tag_key
		if tag_values_str:
			self.tag_values = tag_values_str.strip('][').replace(' ','').split(',')
		else:
			self.tag_values = None
		self.query = query
		self.nick_regex = nick_regex
	def __init__(self, in_dataset_file,  tag_key = None, tag_values_str = None, query = None, nick_regex = None):
		self.in_dataset_file = in_dataset_file
		self.dataset = datasetsHelperTwopz(in_dataset_file)
		self.orginal = datasetsHelperTwopz(in_dataset_file) #Just a copy to compare
		self.tag_key = tag_key
		if tag_values_str:
			self.tag_values = tag_values_str.strip('][').replace(' ','').split(',')
		else:
			self.tag_values = None
		self.query = query
		self.nick_regex = nick_regex
Exemple #3
0
	def __init__(self, storage_for_output, workbase=".", workdir="TEST_SKIM", use_proxy_variable=False):
		self.storage_for_output = storage_for_output
		self.workdir = os.path.join(workbase, os.path.abspath(workdir))
		if not os.path.exists(self.workdir+"/gc_cfg"):
			os.makedirs(self.workdir+"/gc_cfg")
		self.skimdataset = datasetsHelperTwopz(os.path.join(self.workdir, "skim_dataset.json"))
		backup_dataset = self.skimdataset.json_file_name.replace(".json", "_backup.json")
		self.skimdataset.keep_input_json = False ## will be updated very often
		self.skimdataset.write_to_jsonfile(backup_dataset)
		self.configfile = 'kSkimming_run2_cfg.py'
		self.max_crab_jobs_per_nick = 8000 # 10k is the hard limit
		self.voms_proxy = None
		self.site_storage_access_dict = {
			"T2_DE_DESY" : {
				"dcap" : "dcap://dcache-cms-dcap.desy.de//pnfs/desy.de/cms/tier2/",
				"srm" : "srm://dcache-se-cms.desy.de:8443/srm/managerv2?SFN=/pnfs/desy.de/cms/tier2/",
				"xrootd" : "root://dcache-cms-xrootd.desy.de:1094/",
			},
			"T2_DE_RWTH" : {
				"dcap" : "dcap://grid-dcap-extern.physik.rwth-aachen.de/pnfs/physik.rwth-aachen.de/cms/",
				"srm" : "srm://grid-srm.physik.rwth-aachen.de:8443/srm/managerv2\?SFN=/pnfs/physik.rwth-aachen.de/cms/",
				"xrootd" : "root://grid-vo-cms.physik.rwth-aachen.de:1094/",
			}
		}
		self.UsernameFromSiteDB = None
		try:
			self.voms_proxy=os.environ['X509_USER_PROXY']
		except:
			pass
Exemple #4
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)

    ## fill config:
    # includes
    includes = []
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config[
        "BTaggedJetID_documentation"] = "https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsToTauTauWorking2016#b_tagging"
    config[
        "BTaggedJetCombinedSecondaryVertexName"] = "pfCombinedInclusiveSecondaryVertexV2BJetTags"
    config["BTaggedJetCombinedSecondaryVertexMediumWP"] = 0.8484
    config["BTaggerWorkingPoints"] = [
        "tight:0.9535", "medium:0.8484", "loose:0.5426"
    ]
    config["BTaggedJetAbsEtaCut"] = 2.4
    config["ApplyBTagSF"] = not isEmbedded
    config["JetTaggerUpperCuts"] = []
    config["BTagSFMethod"] = "PromotionDemotion"

    return config
 def __init__(self, database_path):
     if not os.path.exists(database_path):
         logger.fatal(
             "Database file does not exist: {}".format(database_path))
         raise Exception
     from Kappa.Skimming.datasetsHelperTwopz import datasetsHelperTwopz
     self._datasets_helper = datasetsHelperTwopz(database_path)
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("(DY.?JetsToLL|EWKZ2Jets)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = []
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["EventWeight"] = "eventWeight"
    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.lheWeights"
    ).build_list()
    config["Quantities"].extend(
        ["isZtt", "isZmt", "isZet", "isZem", "isZee", "isZmm"])
    config["Processors"] = []
    config["Consumers"] = ["KappaLambdaNtupleConsumer"] if re.search(
        "HToTauTau|H2JetsToTauTau", nickname) else []

    # pipelines - systematic shifts
    config2 = jsonTools.JsonDict()
    config2["inclusive"] = config
    return config2
Exemple #7
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)

    ## fill config:
    # includes
    includes = []
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config[
        "BTaggedJetID_documentation"] = "https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsToTauTauWorking2016#b_tagging"

    # settings for CSVv2 algorithm 94X recommendation
    config[
        "BTagScaleFactorFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/CSVv2_94XSF_V1_B_F.csv"
    config[
        "BTagEfficiencyFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/tagging_efficiencies_moriond2017.root"
    config[
        "BTaggedJetCombinedSecondaryVertexName"] = "pfCombinedInclusiveSecondaryVertexV2BJetTags"
    config["BTaggerWorkingPoints"] = [
        "tight:0.9693", "medium:0.8838", "loose:0.5803"
    ]

    # settings for DeepCSV algorithm 94X recommendation (stated to perform better than CSVv2)
    #config["BTagScaleFactorFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/DeepCSV_94XSF_V1_B_F.csv"
    #config["BTagEfficiencyFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/tagging_efficiencies_moriond2017.root"
    #config["BTaggedJetCombinedSecondaryVertexName"] = "pfDeepCSVJetTagsprobbb+pfDeepCSVJetTagsprobb"
    #config["BTaggerWorkingPoints"] = [
    #  "tight:0.8001",
    #  "medium:0.4941",
    #  "loose:0.1522"
    #]

    config["BTaggedJetAbsEtaCut"] = 2.5  # 2017 value
    config["ApplyBTagSF"] = True
    config["JetTaggerUpperCuts"] = []
    config["BTagSFMethod"] = "PromotionDemotion"
    config["BTagShift"] = 0
    config["BMistagShift"] = 0

    ## further settings taken into account by ValidBTaggedJetsProducer:
    # - Year (should be 2017), written into the 'base' config

    ## further hard-coded settings in the ValidBTaggedJetsProducer:
    # lower pt_cut for the Jet: 20 GeV -> valid for 2016 & 2017
    # upper pt_cut for the Jet: 1000 GeV -> valid for 2016 & 2017
    # parton flavour definition: hadron-based

    return config
Exemple #8
0
	def nick_list(self, in_dataset_file, tag_key = None, tag_values_str = None, query = None, nick_regex = None):
		self.inputdataset = datasetsHelperTwopz(in_dataset_file)
		tag_values = None
		if tag_key is None and query is None and nick_regex is None:
			return None
		if tag_values_str:
			tag_values = tag_values_str.strip('][').replace(' ', '').split(',')
		
		return(self.inputdataset.get_nick_list(tag_key=tag_key, tag_values=tag_values, query=query, nick_regex=nick_regex))
Exemple #9
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    #isTTbar = re.search("TT(To|_|Jets)", nickname)
    #isDY = re.search("DY.?JetsToLL", nickname)
    #isWjets = re.search("W.?JetsToLNu", nickname)
    hasBoson = re.search(
        "DY.?JetsToLLM(10to50|50|150)|EWKZ2Jets|^(GluGlu|GluGluTo|VBF|Wminus|Wplus|Z)(HToTauTau|H2JetsToTauTau)|SUSY(BB|GluGlu|GluGluTo)(BB)?HToTauTau",
        nickname)

    ## fill config:
    # includes
    includes = []
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    #config["Processors"] = ["#producer:PrintGenParticleDecayTreeProducer",
    #				"#filter:RunLumiEventFilter"]
    config["Processors"] = ["filter:JsonFilter"] if (isData or re.search(
        "Embedding201", nickname)) else []  #["filter:RunLumiEventFilter"]
    config["Processors"].append("producer:NicknameProducer")
    if not isData:
        if hasBoson:
            config["Processors"].extend(
                ("producer:GenBosonFromGenParticlesProducer",
                 "producer:GenBosonDiLeptonDecayModeProducer",
                 "producer:ValidGenTausProducer",
                 "producer:GenDiLeptonDecayModeProducer"))
        config["Processors"].extend(
            ("producer:GenParticleProducer",
             "producer:RecoElectronGenParticleMatchingProducer",
             "producer:RecoElectronGenTauMatchingProducer",
             "producer:RecoMuonGenParticleMatchingProducer",
             "producer:RecoMuonGenTauMatchingProducer",
             "producer:RecoTauGenParticleMatchingProducer",
             "producer:RecoTauGenTauMatchingProducer",
             "producer:MatchedLeptonsProducer",
             "producer:CrossSectionWeightProducer",
             "producer:GeneratorWeightProducer",
             "producer:NumberGeneratedEventsWeightProducer"))
        if not isEmbedded:
            config["Processors"].append("producer:PUWeightProducer")
    config["Processors"].extend(
        ("filter:MetFilter", "producer:MetFilterFlagProducer"))
    return config
Exemple #10
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    config["Quantities"] = [
        "npu", "numberGeneratedEventsWeight", "crossSectionPerEventWeight",
        "generatorWeight", "npartons", "genbosonmass"
    ]

    config["Consumers"] = ["KappaLambdaNtupleConsumer"]

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'pu', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.syst_shifts_nom"
        ).build_config(nickname))
Exemple #11
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(10to50|50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsKappa"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["SkipEvents"] = 0
    config["EventCount"] = -1
    config["InputIsData"] = False
    BosonPdgIds = {
        "DY.?JetsToLL|EWKZ2Jets|Embedding(2016|MC)": [23],
        "^(GluGlu|GluGluTo|VBF|Wminus|Wplus|Z)(HToTauTau|H2JetsToTauTau)":
        [25],
        "W.?JetsToLN|EWKW": [24],
        "SUSY(BB|GluGlu|GluGluTo)(BB)?HToTauTau": [25, 35, 36]
    }
    config["BosonPdgIds"] = [0]
    for key, pdgids in BosonPdgIds.items():
        if re.search(key, nickname): config["BosonPdgIds"] = pdgids

    config["BosonStatuses"] = [62]

    config["OutputPath"] = "output.root"

    config["Processors"] = []
    config["Processors"].append("producer:NicknameProducer")
    config["Processors"].extend(
        ("producer:CrossSectionWeightProducer",
         "producer:GeneratorWeightProducer",
         "producer:NumberGeneratedEventsWeightProducer"))
    if isWjets or isDY:
        config["Processors"].append(
            "producer:GenBosonFromGenParticlesProducer")
    if isDY or isEmbedded:
        config["Processors"].append("producer:GenDiLeptonDecayModeProducer")
    config["Processors"].extend(
        ("producer:GenParticleProducer", "producer:GenPartonCounterProducer"))
    if isWjets or isDY or isEmbedded:
        config["Processors"].append(
            "producer:GenBosonDiLeptonDecayModeProducer")

    # pipelines - channels including systematic shifts
    config["Pipelines"] = jsonTools.JsonDict()
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2PileUpReweighting2017.pu"
    ).build_config(nickname)

    return config
Exemple #12
0
	def build_config(self, nickname, *args, **kwargs):                #Maybe change this the arguments to process/year and DATA/MC
		"""
		"include" : [
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsVetoMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJEC.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJECUncertaintySplit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsBTaggedJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsSvfit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMinimalPlotlevelFilter_mt.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Includes/settingsMVATestMethods.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauES.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2CPStudies/Includes/settingsTauPolarisationMva.json"
		],
		"""

		datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

		# define frequently used conditions
		isEmbedded = datasetsHelper.isEmbedded(nickname)
		isData = datasetsHelper.isData(nickname) and (not isEmbedded)

		ElectronID_config = sEID.Electron_ID(nickname)
		ElectronID_config.looseElectron_ID(nickname) 		#append the config for loose electron ID because it is used
		self.update(ElectronID_config)

		MuonID_config = sMID.Muon_ID(nickname)
		MuonID_config.looseMuon_ID(nickname) 		#append the config for loose Muon ID because it is used
		MuonID_config.vetoMuon_ID(nickname)
		self.update(MuonID_config)

		TauID_config = sTID.Tau_ID(nickname)			#here loose is not appended since loose tau ID is not used
		self.update(TauID_config)

		JEC_config = sJEC.JEC(nickname)  #Is allready in baseconfig, for now leave it in; possibly remove it
		self.update(JEC_config)

		JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
		self.update(JECUncertaintySplit_config)

		JetID_config = sJID.Jet_ID(nickname)
		self.update(JetID_config)

		BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
		self.update(BTaggedJet_config)

		Svfit_config = sSvfit.Svfit(nickname)
		self.update(Svfit_config)

		MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
		MinimalPlotlevelFilter_config.mt()
		self.update(MinimalPlotlevelFilter_config)
		
		MVATestMethods_config = sMVATM.MVATestMethods()
		self.update(MVATestMethods_config)

		TauES_config = sTES.TauES(nickname)
		self.update(TauES_config)
		
		TauPolarisationMva_config = sTPMVA.TauPolarisationMva()
		self.update(TauPolarisationMva_config)

		self["TauPolarisationTmvaWeights"] = [
			"/afs/cern.ch/user/m/mfackeld/public/weights_tmva/training.weights.xml",
			"/afs/cern.ch/user/m/mfackeld/public/weights_sklearn/training_mt.weights.xml"
		]
		self["Channel"] = "MT"
		self["MinNMuons"] = 1
		self["MinNTaus"] = 1
		self["HltPaths_comment"] = "The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer."

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["HltPaths"] = ["HLT_IsoMu18"]
			self["NoHltFiltering"] = False
			self["DiTauPairNoHLT"] = False

		elif re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["HltPaths"] = [
				"HLT_IsoMu22",
				"HLT_IsoTkMu22",
				"HLT_IsoMu22_eta2p1",
				"HLT_IsoTkMu22_eta2p1",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1"
			]
			self["NoHltFiltering"] = True if isEmbedded else False
			self["DiTauPairNoHLT"] = False

		# elif re.search("Embedding(2016|MC)", nickname):
		# 	self["HltPaths"] = []
		# 	self["NoHltFiltering"] = True
		# 	self["DiTauPairNoHLT"] = True

		self["TauID"] = "TauIDRecommendation13TeV"
		self["TauUseOldDMs"] = True

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["MuonLowerPtCuts"] = ["19.0"]

		else:
			self["MuonLowerPtCuts"] = ["20.0"]
		
		
		self["MuonUpperAbsEtaCuts"] = ["2.1"]
		self["TauLowerPtCuts"] = ["20.0"]
		self["TauUpperAbsEtaCuts"] = ["2.3"]
		self["TriggerObjectLowerPtCut"] = -1.0
		self["DiTauPairMinDeltaRCut"] = 0.5
		self["DiTauPairIsTauIsoMVA"] = True

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["DiTauPairLepton1LowerPtCuts"] = [
				"HLT_IsoMu18_v:19.0"
			]
			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
				"HLT_IsoMu18_v"
			]
		elif re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["DiTauPairLepton1LowerPtCuts"] = [
				"HLT_IsoMu24_v:25.0",
				"HLT_IsoTkMu24_v:25.0"
			]
			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
				"HLT_IsoMu22_v",
				"HLT_IsoTkMu22_v",
				"HLT_IsoMu22_eta2p1_v",
				"HLT_IsoTkMu22_eta2p1_v",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v"
			]
		
		else:                                         #I believe "Run2016|Spring16|Summer16|Embedding(2016|MC)" is everything else but for safety i did it here, 2017 not included yet
			self["DiTauPairLepton1LowerPtCuts"] = [
				"HLT_IsoMu24_v:25.0",
				"HLT_IsoTkMu24_v:25.0"
			]
		
		if re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["DiTauPairHLTLast"] = True
			self["HLTBranchNames"] = [
				"trg_singlemuon:HLT_IsoMu22_v",
				"trg_singlemuon:HLT_IsoTkMu22_v",
				"trg_singlemuon:HLT_IsoMu22_eta2p1_v",
				"trg_singlemuon:HLT_IsoTkMu22_eta2p1_v",
				"trg_mutaucross:HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v",
				"trg_mutaucross:HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v"
			]

			self["MuonTriggerFilterNames"] = [
				"HLT_IsoMu22_v:hltL3crIsoL1sMu20L1f0L2f10QL3f22QL3trkIsoFiltered0p09",
				"HLT_IsoTkMu22_v:hltL3fL1sMu20L1f0Tkf22QL3trkIsoFiltered0p09",
				"HLT_IsoMu22_eta2p1_v:hltL3crIsoL1sSingleMu20erL1f0L2f10QL3f22QL3trkIsoFiltered0p09",
				"HLT_IsoTkMu22_eta2p1_v:hltL3fL1sMu20erL1f0Tkf22QL3trkIsoFiltered0p09",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltL3crIsoL1sMu18erTauJet20erL1f0L2f10QL3f19QL3trkIsoFiltered0p09",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltOverlapFilterIsoMu19LooseIsoPFTau20",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltL3crIsoL1sSingleMu18erIorSingleMu20erL1f0L2f10QL3f19QL3trkIsoFiltered0p09",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltOverlapFilterSingleIsoMu19LooseIsoPFTau20"
			]

			self["TauTriggerFilterNames"] = [
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltL1sMu18erTau20er",
				#"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltOverlapFilterIsoMu19LooseIsoPFTau20",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltL1sSingleMu18erIorSingleMu20er",
				#"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltPFTau20TrackLooseIsoAgainstMuon",
				#"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltOverlapFilterSingleIsoMu19LooseIsoPFTau20"
			]

	
		elif re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["MuonTriggerFilterNames"] = [
				"HLT_IsoMu18_v:hltL3crIsoL1sMu16L1f0L2f10QL3f18QL3trkIsoFiltered0p09"
			]
			self["DiTauPairHLTLast"] = False
		else:
			self["DiTauPairHLTLast"] = False
		
		self["EventWeight"] = "eventWeight"
		self["SaveRooWorkspaceTriggerWeightAsOptionalOnly"] = "true"
		if isEmbedded:
			self["EmbeddingWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_11_embedded.root"
			self["EmbeddingWeightWorkspaceWeightNames"] = [
				"0:triggerWeight_doublemu",
				"0:isoweight",
				"0:idweight",
				"0:triggerWeight_singleMu",

				"1:MuTau_TauLeg_EmbeddedEfficiencyWeight",
				"1:MuTau_TauLeg_DataEfficiencyWeight"
			]
			self["EmbeddingWeightWorkspaceObjectNames"] = [
				"0:m_sel_trg_ratio",
				"0:m_iso_ratio",
				"0:m_id_ratio",
				"0:m_trg_ratio",

				"1:t_TightIso_mt_emb",
				"1:t_genuine_TightIso_mt_data,t_fake_TightIso_mt_data"
			]
			self["EmbeddingWeightWorkspaceObjectArguments"] = [
				"0:gt1_pt,gt1_eta,gt2_pt,gt2_eta",
				"0:m_pt,m_eta",
				"0:m_pt,m_eta",
				"0:m_pt,m_eta",

				"1:t_pt,t_eta",
				"1:t_pt,t_eta"
			]
		else:
			self["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
			self["RooWorkspaceWeightNames"] = [
				"0:triggerWeight_singleMu",
				"0:idIsoWeight"
			]
			self["RooWorkspaceObjectNames"] = [
				"0:m_trgMu22OR_eta2p1_desy_ratio",
				"0:m_idiso0p15_desy_ratio"
			]
			self["RooWorkspaceObjectArguments"] = [
				"0:m_pt,m_eta",
				"0:m_pt,m_eta"
			]
			self["SaveMuTauTriggerWeightAsOptionalOnly"] = "true"
			self["MuTauTriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
			self["MuTauTriggerWeightWorkspaceWeightNames"] = [
				"0:triggerWeight_muTauCross",
				"1:triggerWeight_muTauCross"
			]
			self["MuTauTriggerWeightWorkspaceObjectNames"] = [
				"0:m_trgMu19leg_eta2p1_desy_ratio",
				"1:t_genuine_TightIso_mt_ratio,t_fake_TightIso_mt_ratio"
			]
			self["MuTauTriggerWeightWorkspaceObjectArguments"] = [
				"0:m_pt,m_eta",
				"1:t_pt,t_eta"
			]

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["TriggerEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Muon_IsoMu18_fall15.root"]
			self["TriggerEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_IsoMu18_fall15.root"]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2015_Muon_IdIso0p1_fall15.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso0p1_fall15.root"]		

		else:
			self["TriggerEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu22OR_eta2p1_eff.root"]
			self["TriggerEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu22OR_eta2p1_eff.root"]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root"]

		self["TriggerEfficiencyMode"] = "multiply_weights"
		self["IdentificationEfficiencyMode"] = "multiply_weights"
		self["EleTauFakeRateWeightFile"] = [
			"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
		]
		self["TauTauRestFrameReco"] =  "collinear_approximation"
		self["InvalidateNonMatchingElectrons"] =  False
		self["InvalidateNonMatchingMuons"] =  True
		self["InvalidateNonMatchingTaus"] =  True
		self["InvalidateNonMatchingJets"] =  False
		self["UseUWGenMatching"] =  "true"
		self["DirectIso"] =  True
		self["OSChargeLeptons"] = True
		self["SvfitKappaParameter"] = 4.0

		self["AddGenMatchedParticles"] = True
		self["AddGenMatchedTaus"] = True
		self["AddGenMatchedTauJets"] = True
		self["BranchGenMatchedMuons"] = True
		self["BranchGenMatchedTaus"] = True

		if re.search("Run2016|Spring16|Summer16|Embedding2016", nickname):
			#settings for jetstotaufakesproducer
			self["FakeFaktorFile"] = "root://grid-vo-cms.physik.rwth-aachen.de:1094//store/user/jdegens/higgs-kit/ff/2016/mt/fakeFactors_20180831_tight.root"
			self["FakeFactorMethod"] = "cp2016"
			self["FakeFactorRooWorkspaceFunction"] = [
				"w_fracs:w_mt_fracs",
				"qcd_fracs:qcd_mt_fracs",
				"ttbar_fracs:ttbar_mt_fracs"
			]
			self["FakeFactorFractionsRooWorkspaceFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/rooworkspacefractions/ff_fracs_new_2016.root"


		self["Consumers"] = [
			"KappaLambdaNtupleConsumer",
			"cutflow_histogram",
			"SvfitCacheConsumer",
			"#CutFlowTreeConsumer",
			"#KappaMuonsConsumer",
			"#KappaTausConsumer",
			"#KappaTaggedJetsConsumer",
			"#RunTimeConsumer",
			"#PrintEventsConsumer",
			"#PrintGenParticleDecayTreeConsumer"
		]

		quantities_dict = quantities.quantities() 
		quantities_dict.build_quantities(nickname, channel = self["Channel"])

		quantities_dict["Quantities"] += [
				"nVetoMuons",
				"nLooseElectrons",
				"nLooseMuons",
				"nDiTauPairCandidates",
				"nAllDiTauPairCandidates"
			] #Check if they are used everywhere if so make this the start list

		#put rest of quantities in CPQuantities.py?
		
		if re.search("(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16))", nickname):	 #the same as tt

			# quantities_dict["Quantities"] += quantities_dict.lheWeightsDYQuantities()
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]

		elif re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]

		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):

			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]    #commented out: "#tauPolarisationTMVA", "#tauPolarisationSKLEARN",



		elif re.search("Embedding2016", nickname):

			quantities_dict["Quantities"] += quantities_dict.genQuantities()
			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"triggerWeight_doublemu_1",
				"isoweight_1",
				"idweight_1",
				"triggerWeight_singleMu_1",
				"trg_mutaucross",
				"triggerWeight_muTauCross_2",
				"MuTau_TauLeg_EmbeddedEfficiencyWeight_2",
				"MuTau_TauLeg_DataEfficiencyWeight_2"
			]
		
		elif re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += [
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2",
				"jetCorrectionWeight"
			]

		elif re.search("Run2016", nickname):
			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]
		elif re.search("Run2015", nickname):
			pass
		elif re.search("^((?!(DY.?JetsTo(LL|TauTau)|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
			pass
		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)", nickname):
			pass
		
		else:
			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]

		self.update(copy.deepcopy(quantities_dict))


		self["Processors"] = [
				"producer:HltProducer",
				"filter:HltFilter",
				"producer:MetSelector",
				################## special for each channel in et mt tt em.
				"producer:ValidMuonsProducer",
				"filter:ValidMuonsFilter",
				"producer:MuonTriggerMatchingProducer",
				"filter:MinMuonsCountFilter",
				"producer:ValidElectronsProducer",
				"producer:ValidTausProducer",
				"filter:ValidTausFilter",
				"producer:TauTriggerMatchingProducer",
				"filter:MinTausCountFilter",
				"producer:ValidMTPairCandidatesProducer",
				"filter:ValidDiTauPairCandidatesFilter",
				"producer:HttValidVetoMuonsProducer",
				"producer:HttValidLooseElectronsProducer",
				"producer:HttValidLooseMuonsProducer",
				##################
				"producer:Run2DecayChannelProducer",          
				"producer:DiVetoMuonVetoProducer",
				"producer:TaggedJetCorrectionsProducer",
				"producer:ValidTaggedJetsProducer",
				"producer:ValidBTaggedJetsProducer",	
				"producer:TauTauRestFrameSelector",
				"producer:DiLeptonQuantitiesProducer",
				"producer:DiJetQuantitiesProducer",
				
				]
		



		if re.search("(Spring16|Summer16|Run2016|Embedding2016)", nickname):
			self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["producer:TaggedJetUncertaintyShiftProducer"]

			if re.search("(Run2016|Embedding2016)", nickname):
				self["Processors"] += ["producer:JetToTauFakesProducer"]
				#self["Processors"] += ["producer:MVATestMethodsProducer"]
						
				self["Processors"] += ["producer:SimpleFitProducer"]
				#self["Processors"] += ["producer:GenMatchedTauCPProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				self["Processors"] += ["filter:MinimalPlotlevelFilter"]
				self["Processors"] += ["producer:SvfitProducer"]
				self["Processors"] += ["producer:SvfitM91Producer"]
#				self["Processors"] += ["producer:SvfitM125Producer"]

				self["Processors"] += ["producer:MELAProducer"]
#				self["Processors"] += ["producer:MELAM125Producer"]

				if re.search("Embedding2016", nickname):
					self["Processors"] += ["producer:RooWorkspaceWeightProducer"] #do this properly after checking
					self["Processors"] += ["producer:EmbeddingWeightProducer"]
					self["Processors"] += ["producer:MuTauTriggerWeightProducer"]
					self["Processors"] += ["producer:TauCorrectionsProducer"]

				#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

			else:
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:RooWorkspaceWeightProducer"]
				self["Processors"] += ["producer:MuTauTriggerWeightProducer"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += [
						"producer:SimpleEleTauFakeRateWeightProducer",
						"producer:SimpleMuTauFakeRateWeightProducer"
						]
			
				if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
					self["Processors"] += [
						"producer:ZPtReweightProducer"
						#"filter:MinimalPlotlevelFilter"
					]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:LFVJetCorrection2016Producer"]

				else:              
					self["Processors"] += ["filter:MinimalPlotlevelFilter"]
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
#					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]
	
					if re.search("(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += ["producer:JetToTauFakesProducer"]
						self["Processors"] += ["producer:ZPtReweightProducer"]			

						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

					elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += [
							"producer:TopPtReweightingProducer"
						] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"] # I put this on in to create the same config as json but i dont think it is needed
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
						#self["Processors"] += ["producer:MadGraphReweightingProducer"]
					else:
						self["Processors"] += ["producer:JetToTauFakesProducer"]
						self["Processors"] += [	"producer:TopPtReweightingProducer"] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:SimpleFitProducer"]				
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
						
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

		elif re.search("(Fall15|Run2015)", nickname):
			#self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["filter:MinimalPlotlevelFilter"]
			self["Processors"] += ["producer:MvaMetSelector"]

			
			if re.search("Run2015", nickname):
				#self["Processors"] += ["producer:SimpleFitProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
				
				#self["Processors"] += ["producer:SvfitProducer"]
				#self["Processors"] += ["producer:SvfitM91Producer"]
				#self["Processors"] += ["producer:SvfitM125Producer"]

				#self["Processors"] += ["producer:MELAProducer"]
				#self["Processors"] += ["producer:MELAM125Producer"]

			else:
				self["Processors"] += ["producer:MvaMetCorrector"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:TriggerWeightProducer",
					"producer:IdentificationWeightProducer",
					"producer:EleTauFakeRateWeightProducer"
				]

				if re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):

					self["Processors"] += ["producer:ZPtReweightProducer"]			
					#self["Processors"] += ["producer:SimpleFitProducer"]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
#					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]



				elif re.search("^((?!(DY.?JetsTo(LL|TauTau)|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
#					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

		self["Processors"] += ["producer:EventWeightProducer"]
		self["Processors"] = list(set(self["Processors"]))
		processorOrderingkey = processorOrdering.processors_ordered(channel = self["Channel"])
		ordered_processors = processorOrderingkey.order_processors(self["Processors"]) 
		self["Processors"] = copy.deepcopy(ordered_processors)
	def build_config(self, nickname, *args, **kwargs):                #Maybe change this the arguments to process/year and DATA/MC
		"""
		"include" : [
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsVetoMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJEC.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJECUncertaintySplit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsBTaggedJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsSvfit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMinimalPlotlevelFilter_mt.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Includes/settingsMVATestMethods.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauES.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2CPStudies/Includes/settingsTauPolarisationMva.json"
		],
		"""

		datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

		# define frequently used conditions
		isEmbedded = datasetsHelper.isEmbedded(nickname)
		isData = datasetsHelper.isData(nickname) and (not isEmbedded)

		ElectronID_config = sEID.Electron_ID(nickname)
		ElectronID_config.looseElectron_ID(nickname) 		#append the config for loose electron ID because it is used
		self.update(ElectronID_config)

		MuonID_config = sMID.Muon_ID(nickname)
		MuonID_config.looseMuon_ID(nickname) 		#append the config for loose Muon ID because it is used
		MuonID_config.vetoMuon_ID(nickname)
		self.update(MuonID_config)

		TauID_config = sTID.Tau_ID(nickname)			#here loose is not appended since loose tau ID is not used
		self.update(TauID_config)

		JEC_config = sJEC.JEC(nickname)  #Is allready in baseconfig, for now leave it in; possibly remove it
		self.update(JEC_config)

		JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
		self.update(JECUncertaintySplit_config)

		JetID_config = sJID.Jet_ID(nickname)
		self.update(JetID_config)

		BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
		self.update(BTaggedJet_config)

		Svfit_config = sSvfit.Svfit(nickname)
		self.update(Svfit_config)

		MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
		MinimalPlotlevelFilter_config.mt()
		self.update(MinimalPlotlevelFilter_config)
		
		MVATestMethods_config = sMVATM.MVATestMethods()
		self.update(MVATestMethods_config)

		TauES_config = sTES.TauES(nickname)
		self.update(TauES_config)
		
		TauPolarisationMva_config = sTPMVA.TauPolarisationMva()
		self.update(TauPolarisationMva_config)

		self["TauPolarisationTmvaWeights"] = [
			"/afs/cern.ch/user/m/mfackeld/public/weights_tmva/training.weights.xml",
			"/afs/cern.ch/user/m/mfackeld/public/weights_sklearn/training_mt.weights.xml"
		]
		self["Channel"] = "MT"
		self["MinNMuons"] = 1
		self["MinNTaus"] = 1
		self["HltPaths_comment"] = "The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer."

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["HltPaths"] = ["HLT_IsoMu18"]
			self["NoHltFiltering"] = False
			self["DiTauPairNoHLT"] = False

		elif re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["HltPaths"] = [
				"HLT_IsoMu22",
				"HLT_IsoTkMu22",
				"HLT_IsoMu22_eta2p1",
				"HLT_IsoTkMu22_eta2p1",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1"
			]
			self["NoHltFiltering"] = True if isEmbedded else False
			self["DiTauPairNoHLT"] = False

		# elif re.search("Embedding(2016|MC)", nickname):
		# 	self["HltPaths"] = []
		# 	self["NoHltFiltering"] = True
		# 	self["DiTauPairNoHLT"] = True

		self["TauID"] = "TauIDRecommendation13TeV"
		self["TauUseOldDMs"] = True

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["MuonLowerPtCuts"] = ["19.0"]

		else:
			self["MuonLowerPtCuts"] = ["20.0"]
		
		
		self["MuonUpperAbsEtaCuts"] = ["2.1"]
		self["TauLowerPtCuts"] = ["20.0"]
		self["TauUpperAbsEtaCuts"] = ["2.3"]
		self["TriggerObjectLowerPtCut"] = -1.0
		self["DiTauPairMinDeltaRCut"] = 0.5
		self["DiTauPairIsTauIsoMVA"] = True

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["DiTauPairLepton1LowerPtCuts"] = [
				"HLT_IsoMu18_v:19.0"
			]
			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
				"HLT_IsoMu18_v"
			]
		elif re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["DiTauPairLepton1LowerPtCuts"] = [
				"HLT_IsoMu24_v:25.0",
				"HLT_IsoTkMu24_v:25.0"
			]
			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
				"HLT_IsoMu22_v",
				"HLT_IsoTkMu22_v",
				"HLT_IsoMu22_eta2p1_v",
				"HLT_IsoTkMu22_eta2p1_v",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v"
			]
		
		else:                                         #I believe "Run2016|Spring16|Summer16|Embedding(2016|MC)" is everything else but for safety i did it here, 2017 not included yet
			self["DiTauPairLepton1LowerPtCuts"] = [
				"HLT_IsoMu24_v:25.0",
				"HLT_IsoTkMu24_v:25.0"
			]
		
		if re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["DiTauPairHLTLast"] = True
			self["HLTBranchNames"] = [
				"trg_singlemuon:HLT_IsoMu22_v",
				"trg_singlemuon:HLT_IsoTkMu22_v",
				"trg_singlemuon:HLT_IsoMu22_eta2p1_v",
				"trg_singlemuon:HLT_IsoTkMu22_eta2p1_v",
				"trg_mutaucross:HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v",
				"trg_mutaucross:HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v"
			]

			self["MuonTriggerFilterNames"] = [
				"HLT_IsoMu22_v:hltL3crIsoL1sMu20L1f0L2f10QL3f22QL3trkIsoFiltered0p09",
				"HLT_IsoTkMu22_v:hltL3fL1sMu20L1f0Tkf22QL3trkIsoFiltered0p09",
				"HLT_IsoMu22_eta2p1_v:hltL3crIsoL1sSingleMu20erL1f0L2f10QL3f22QL3trkIsoFiltered0p09",
				"HLT_IsoTkMu22_eta2p1_v:hltL3fL1sMu20erL1f0Tkf22QL3trkIsoFiltered0p09",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltL3crIsoL1sMu18erTauJet20erL1f0L2f10QL3f19QL3trkIsoFiltered0p09",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltOverlapFilterIsoMu19LooseIsoPFTau20",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltL3crIsoL1sSingleMu18erIorSingleMu20erL1f0L2f10QL3f19QL3trkIsoFiltered0p09",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltOverlapFilterSingleIsoMu19LooseIsoPFTau20"
			]

			self["TauTriggerFilterNames"] = [
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltL1sMu18erTau20er",
				#"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_v:hltOverlapFilterIsoMu19LooseIsoPFTau20",
				"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltL1sSingleMu18erIorSingleMu20er",
				#"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltPFTau20TrackLooseIsoAgainstMuon",
				#"HLT_IsoMu19_eta2p1_LooseIsoPFTau20_SingleL1_v:hltOverlapFilterSingleIsoMu19LooseIsoPFTau20"
			]

	
		elif re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["MuonTriggerFilterNames"] = [
				"HLT_IsoMu18_v:hltL3crIsoL1sMu16L1f0L2f10QL3f18QL3trkIsoFiltered0p09"
			]
			self["DiTauPairHLTLast"] = False
		else:
			self["DiTauPairHLTLast"] = False
		
		self["EventWeight"] = "eventWeight"
		self["SaveRooWorkspaceTriggerWeightAsOptionalOnly"] = "true"
		if isEmbedded:
			self["EmbeddingWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_11_embedded.root"
			self["EmbeddingWeightWorkspaceWeightNames"] = [
				"0:triggerWeight_doublemu",
				"0:isoweight",
				"0:idweight",
				"0:triggerWeight_singleMu",

				"1:MuTau_TauLeg_EmbeddedEfficiencyWeight",
				"1:MuTau_TauLeg_DataEfficiencyWeight"
			]
			self["EmbeddingWeightWorkspaceObjectNames"] = [
				"0:m_sel_trg_ratio",
				"0:m_iso_ratio",
				"0:m_id_ratio",
				"0:m_trg_ratio",

				"1:t_TightIso_mt_emb",
				"1:t_genuine_TightIso_mt_data,t_fake_TightIso_mt_data"
			]
			self["EmbeddingWeightWorkspaceObjectArguments"] = [
				"0:gt1_pt,gt1_eta,gt2_pt,gt2_eta",
				"0:m_pt,m_eta",
				"0:m_pt,m_eta",
				"0:m_pt,m_eta",

				"1:t_pt,t_eta",
				"1:t_pt,t_eta"
			]
		else:
			self["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
			self["RooWorkspaceWeightNames"] = [
				"0:triggerWeight_singleMu",
				"0:idIsoWeight"
			]
			self["RooWorkspaceObjectNames"] = [
				"0:m_trgMu22OR_eta2p1_desy_ratio",
				"0:m_idiso0p15_desy_ratio"
			]
			self["RooWorkspaceObjectArguments"] = [
				"0:m_pt,m_eta",
				"0:m_pt,m_eta"
			]
			self["SaveMuTauTriggerWeightAsOptionalOnly"] = "true"
			self["MuTauTriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
			self["MuTauTriggerWeightWorkspaceWeightNames"] = [
				"0:triggerWeight_muTauCross",
				"1:triggerWeight_muTauCross"
			]
			self["MuTauTriggerWeightWorkspaceObjectNames"] = [
				"0:m_trgMu19leg_eta2p1_desy_ratio",
				"1:t_genuine_TightIso_mt_ratio,t_fake_TightIso_mt_ratio"
			]
			self["MuTauTriggerWeightWorkspaceObjectArguments"] = [
				"0:m_pt,m_eta",
				"1:t_pt,t_eta"
			]

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["TriggerEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Muon_IsoMu18_fall15.root"]
			self["TriggerEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_IsoMu18_fall15.root"]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2015_Muon_IdIso0p1_fall15.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso0p1_fall15.root"]		

		else:
			self["TriggerEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu22OR_eta2p1_eff.root"]
			self["TriggerEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu22OR_eta2p1_eff.root"]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root"]

		self["TriggerEfficiencyMode"] = "multiply_weights"
		self["IdentificationEfficiencyMode"] = "multiply_weights"
		self["EleTauFakeRateWeightFile"] = [
			"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
		]
		self["TauTauRestFrameReco"] =  "collinear_approximation"
		self["InvalidateNonMatchingElectrons"] =  False
		self["InvalidateNonMatchingMuons"] =  True
		self["InvalidateNonMatchingTaus"] =  True
		self["InvalidateNonMatchingJets"] =  False
		self["UseUWGenMatching"] =  "true"
		self["DirectIso"] =  True
		self["OSChargeLeptons"] = True
		self["SvfitKappaParameter"] = 4.0

		self["AddGenMatchedParticles"] = True
		self["AddGenMatchedTaus"] = True
		self["AddGenMatchedTauJets"] = True
		self["BranchGenMatchedMuons"] = True
		self["BranchGenMatchedTaus"] = True

		if re.search("Run2016|Spring16|Summer16|Embedding2016", nickname):
			#settings for jetstotaufakesproducer
			self["FakeFaktorFile"] = "root://grid-vo-cms.physik.rwth-aachen.de:1094//store/user/jdegens/higgs-kit/ff/2016/mt/fakeFactors_20180831_tight.root"
			self["FakeFactorMethod"] = "cp2016"
			self["FakeFactorRooWorkspaceFunction"] = [
				"w_fracs:w_mt_fracs",
				"qcd_fracs:qcd_mt_fracs",
				"ttbar_fracs:ttbar_mt_fracs"
			]
			self["FakeFactorFractionsRooWorkspaceFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/rooworkspacefractions/ff_fracs_new_2016.root"


		self["Consumers"] = [
			"KappaLambdaNtupleConsumer",
			"cutflow_histogram",
			"SvfitCacheConsumer",
			"#CutFlowTreeConsumer",
			"#KappaMuonsConsumer",
			"#KappaTausConsumer",
			"#KappaTaggedJetsConsumer",
			"#RunTimeConsumer",
			"#PrintEventsConsumer",
			"#PrintGenParticleDecayTreeConsumer"
		]

		quantities_dict = quantities.quantities() 
		quantities_dict.build_quantities(nickname, channel = self["Channel"])

		quantities_dict["Quantities"] += [
				"nVetoMuons",
				"nLooseElectrons",
				"nLooseMuons",
				"nDiTauPairCandidates",
				"nAllDiTauPairCandidates"
			] #Check if they are used everywhere if so make this the start list

		#put rest of quantities in CPQuantities.py?
		
		if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16))", nickname):	 #the same as tt

			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]

		elif re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]

		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):

			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]    #commented out: "#tauPolarisationTMVA", "#tauPolarisationSKLEARN",



		elif re.search("Embedding2016", nickname):

			quantities_dict["Quantities"] += quantities_dict.genQuantities()
			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"triggerWeight_doublemu_1",
				"isoweight_1",
				"idweight_1",
				"triggerWeight_singleMu_1",
				"trg_mutaucross",
				"triggerWeight_muTauCross_2",
				"MuTau_TauLeg_EmbeddedEfficiencyWeight_2",
				"MuTau_TauLeg_DataEfficiencyWeight_2"
			]
		
		elif re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += [
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2",
				"jetCorrectionWeight"
			]

		elif re.search("Run2016", nickname):
			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]
		elif re.search("Run2015", nickname):
			pass
		elif re.search("^((?!(DY.?JetsToLL|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
			pass
		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)", nickname):
			pass
		
		else:
			quantities_dict["Quantities"] += [
				"trg_singlemuon",
				"trg_mutaucross",
				"triggerWeight_singleMu_1",
				"triggerWeight_muTauCross_1",
				"triggerWeight_muTauCross_2"
			]

		self.update(copy.deepcopy(quantities_dict))


		self["Processors"] = [
				"producer:HltProducer",
				"filter:HltFilter",
				"producer:MetSelector",
				################## special for each channel in et mt tt em.
				"producer:ValidMuonsProducer",
				"filter:ValidMuonsFilter",
				"producer:MuonTriggerMatchingProducer",
				"filter:MinMuonsCountFilter",
				"producer:ValidElectronsProducer",
				"producer:ValidTausProducer",
				"filter:ValidTausFilter",
				"producer:TauTriggerMatchingProducer",
				"filter:MinTausCountFilter",
				"producer:ValidMTPairCandidatesProducer",
				"filter:ValidDiTauPairCandidatesFilter",
				"producer:HttValidVetoMuonsProducer",
				"producer:HttValidLooseElectronsProducer",
				"producer:HttValidLooseMuonsProducer",
				##################
				"producer:Run2DecayChannelProducer",          
				"producer:DiVetoMuonVetoProducer",
				"producer:TaggedJetCorrectionsProducer",
				"producer:ValidTaggedJetsProducer",
				"producer:ValidBTaggedJetsProducer",	
				"producer:TauTauRestFrameSelector",
				"producer:DiLeptonQuantitiesProducer",
				"producer:DiJetQuantitiesProducer",
				
				]
		



		if re.search("(Spring16|Summer16|Run2016|Embedding2016)", nickname):
			self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["producer:TaggedJetUncertaintyShiftProducer"]

			if re.search("(Run2016|Embedding2016)", nickname):
				self["Processors"] += ["producer:JetToTauFakesProducer"]
				#self["Processors"] += ["producer:MVATestMethodsProducer"]
						
				self["Processors"] += ["producer:SimpleFitProducer"]
				#self["Processors"] += ["producer:GenMatchedTauCPProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				self["Processors"] += ["filter:MinimalPlotlevelFilter"]
				self["Processors"] += ["producer:SvfitProducer"]
				self["Processors"] += ["producer:SvfitM91Producer"]
				self["Processors"] += ["producer:SvfitM125Producer"]

				self["Processors"] += ["producer:MELAProducer"]
				self["Processors"] += ["producer:MELAM125Producer"]

				if re.search("Embedding2016", nickname):
					self["Processors"] += ["producer:RooWorkspaceWeightProducer"] #do this properly after checking
					self["Processors"] += ["producer:EmbeddingWeightProducer"]
					self["Processors"] += ["producer:MuTauTriggerWeightProducer"]
					self["Processors"] += ["producer:TauCorrectionsProducer"]

				#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

			else:
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:RooWorkspaceWeightProducer"]
				self["Processors"] += ["producer:MuTauTriggerWeightProducer"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += [
						"producer:SimpleEleTauFakeRateWeightProducer",
						"producer:SimpleMuTauFakeRateWeightProducer"
						]
			
				if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
					self["Processors"] += [
						"producer:ZPtReweightProducer"
						#"filter:MinimalPlotlevelFilter"
					]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:LFVJetCorrection2016Producer"]

				else:              
					self["Processors"] += ["filter:MinimalPlotlevelFilter"]
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]
	
					if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += ["producer:JetToTauFakesProducer"]
						self["Processors"] += ["producer:ZPtReweightProducer"]			

						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

					elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += [
							"producer:TopPtReweightingProducer"
						] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"] # I put this on in to create the same config as json but i dont think it is needed
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
						#self["Processors"] += ["producer:MadGraphReweightingProducer"]
					else:
						self["Processors"] += ["producer:JetToTauFakesProducer"]
						self["Processors"] += [	"producer:TopPtReweightingProducer"] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:SimpleFitProducer"]				
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
						
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

		elif re.search("(Fall15|Run2015)", nickname):
			#self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["filter:MinimalPlotlevelFilter"]
			self["Processors"] += ["producer:MvaMetSelector"]

			
			if re.search("Run2015", nickname):
				#self["Processors"] += ["producer:SimpleFitProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
				
				#self["Processors"] += ["producer:SvfitProducer"]
				#self["Processors"] += ["producer:SvfitM91Producer"]
				#self["Processors"] += ["producer:SvfitM125Producer"]

				#self["Processors"] += ["producer:MELAProducer"]
				#self["Processors"] += ["producer:MELAM125Producer"]

			else:
				self["Processors"] += ["producer:MvaMetCorrector"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:TriggerWeightProducer",
					"producer:IdentificationWeightProducer",
					"producer:EleTauFakeRateWeightProducer"
				]

				if re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):

					self["Processors"] += ["producer:ZPtReweightProducer"]			
					#self["Processors"] += ["producer:SimpleFitProducer"]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]



				elif re.search("^((?!(DY.?JetsToLL|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

		self["Processors"] += ["producer:EventWeightProducer"]
		self["Processors"] = list(set(self["Processors"]))
		processorOrderingkey = processorOrdering.processors_ordered(channel = self["Channel"])
		ordered_processors = processorOrderingkey.order_processors(self["Processors"]) 
		self["Processors"] = copy.deepcopy(ordered_processors)
Exemple #14
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("(DY.?JetsToLL|EWKZ2Jets)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsVetoElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_ee"
        #"HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJECUncertaintySplit",
        #"HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsSvfit",
        #"HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsMVATestMethods"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "EE"
    config["MinNElectrons"] = 2
    # The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
    if isEmbedded: config["HltPaths"] = [""]
    else: config["HltPaths"] = ["HLT_Ele25_eta2p1_WPTight_Gsf"]
    config["HLTBranchNames"] = [
        "trg_singleelectron:HLT_Ele25_eta2p1_WPTight_Gsf_v"
    ]
    config["NoHltFiltering"] = True if isEmbedded else False

    config["TauID"] = "TauIDRecommendation13TeV"
    config["TauUseOldDMs"] = False
    config["ElectronLowerPtCuts"] = ["13.0"]
    config["ElectronUpperAbsEtaCuts"] = ["2.5"]
    config["DeltaRTriggerMatchingElectrons"] = 0.4
    config["DiTauPairMinDeltaRCut"] = 0.3
    if re.search("Run2016|Summer16", nickname):
        config["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
            "HLT_Ele25_eta2p1_WPTight_Gsf_v"
        ]

    config["DiTauPairLepton1LowerPtCuts"] = [
        "HLT_Ele25_eta2p1_WPTight_Gsf_v:26.0",
        "HLT_Ele25_eta2p1_WPTight_Gsf_v:26.0"
    ]
    #config["DiTauPairLepton2LowerPtCuts"] = ["HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:24.0"]

    config["DiTauPairNoHLT"] = False
    config["EventWeight"] = "eventWeight"
    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
    config["RooWorkspaceWeightNames"] = ["0:idIsoWeight", "1:idIsoWeight"]
    config["RooWorkspaceObjectNames"] = [
        "0:e_idiso0p1_desy_ratio", "1:e_idiso0p1_desy_ratio"
    ]
    config["RooWorkspaceObjectArguments"] = ["0:e_pt,e_eta", "1:e_pt,e_eta"]

    config[
        "EETriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
    config["EETriggerWeightWorkspaceWeightNames"] = [
        "0:triggerWeight", "1:triggerWeight"
    ]
    config["EETriggerWeightWorkspaceObjectNames"] = [
        "0:e_trgEle25eta2p1WPTight_desy_ratio",
        "1:e_trgEle25eta2p1WPTight_desy_ratio"
    ]
    config["EETriggerWeightWorkspaceObjectArguments"] = [
        "0:e_pt,e_eta", "1:e_pt,e_eta"
    ]
    #config["TriggerEfficiencyData"] = []
    '''
  config["TriggerEfficiencyMc"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
    "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
    "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root"]
  config["IdentificationEfficiencyData"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root",
    "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root"]
  config["IdentificationEfficiencyMc"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root",
    "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p15_2016BtoH_eff.root"]
  '''
    config["IdentificationEfficiencyMode"] = "multiply_weights"
    config["TauTauRestFrameReco"] = "collinear_approximation"
    config["TriggerEfficiencyMode"] = "correlate_triggers"

    if re.search("Run2016|Summer16", nickname):
        config["ElectronTriggerFilterNames"] = [
            "HLT_Ele25_eta2p1_WPTight_Gsf_v:hltEle25erWPTightGsfTrackIsoFilter"
        ]

    config["InvalidateNonMatchingElectrons"] = True
    config["InvalidateNonMatchingMuons"] = False
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.fourVectorQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.syncQuantities"
        ).build_list())
    #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.svfitSyncQuantities").build_list())
    #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.splitJecUncertaintyQuantities").build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    config["Quantities"].extend([
        "nLooseElectrons", "nLooseMuons", "nDiTauPairCandidates",
        "nAllDiTauPairCandidates", "trg_singleelectron", "lep1ErrD0",
        "lep1ErrDz", "lep2ErrD0", "lep2ErrDz"
    ])

    config["OSChargeLeptons"] = True

    config["Processors"] = [
        "producer:HltProducer", "filter:HltFilter", "producer:MetSelector",
        "producer:ElectronCorrectionsProducer",
        "producer:ValidElectronsProducer", "filter:ValidElectronsFilter",
        "producer:ElectronTriggerMatchingProducer",
        "filter:MinElectronsCountFilter", "producer:ValidMuonsProducer",
        "producer:ValidTausProducer", "producer:ValidEEPairCandidatesProducer",
        "filter:ValidDiTauPairCandidatesFilter",
        "producer:HttValidLooseElectronsProducer",
        "producer:HttValidLooseMuonsProducer",
        "producer:Run2DecayChannelProducer",
        "producer:TaggedJetCorrectionsProducer",
        "producer:ValidTaggedJetsProducer", "producer:ValidBTaggedJetsProducer"
    ]
    #"producer:TaggedJetUncertaintyShiftProducer"]
    if not isData:
        config["Processors"].append(
            "producer:MetCorrector")  #"producer:MvaMetCorrector"
    config["Processors"].extend(("producer:TauTauRestFrameSelector",
                                 "producer:DiLeptonQuantitiesProducer",
                                 "producer:DiJetQuantitiesProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    if isDY: config["Processors"].append("producer:ZPtReweightProducer")
    config["Processors"].append("filter:MinimalPlotlevelFilter")
    #"producer:SvfitProducer")) #"producer:MVATestMethodsProducer"
    if not isData:
        config["Processors"].extend((
            "producer:IdentificationWeightProducer",
            "producer:EETriggerWeightProducer",
            #"producer:TriggerWeightProducer",
            "producer:RooWorkspaceWeightProducer"))
    config["Processors"].append("producer:EventWeightProducer")

    config["AddGenMatchedParticles"] = True
    config["BranchGenMatchedElectrons"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer", "cutflow_histogram"]
    #"SvfitCacheConsumer"]
    #"CutFlowTreeConsumer",
    #"KappaElectronsConsumer",
    #"KappaTausConsumer",
    #"KappaTaggedJetsConsumer",
    #"RunTimeConsumer",
    #"PrintEventsConsumer"

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'ee', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.nominal"
        ).build_config(nickname))
Exemple #15
0
    def build_config(
        self, nickname, *args, **kwargs
    ):  #Maybe change this the arguments to process/year and DATA/MC

        #Change this json config files as well?
        """
		if hasattr(self, "include") == False:
			self["include"] = []
		self["include"] += ["$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseElectronID.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseMuonID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsElectronID.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMuonID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJEC.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJECUncertaintySplit.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJetID.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsBTaggedJetID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsSvfit.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMinimalPlotlevelFilter_tt.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Includes/settingsMVATestMethods.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauES.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2CPStudies/Includes/settingsTauPolarisationMva.json"] #Done
		"""

        datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
            os.path.expandvars(
                "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

        # define frequently used conditions
        isEmbedded = datasetsHelper.isEmbedded(nickname)
        isData = datasetsHelper.isData(nickname) and (not isEmbedded)

        ElectronID_config = sEID.Electron_ID(nickname)
        ElectronID_config.looseElectron_ID(
            nickname
        )  #append the config for loose electron ID because it is used
        self.update(ElectronID_config)

        MuonID_config = sMID.Muon_ID(nickname)
        MuonID_config.looseMuon_ID(
            nickname)  #append the config for loose Muon ID because it is used
        self.update(MuonID_config)

        TauID_config = sTID.Tau_ID(
            nickname
        )  #here loose is not appended since loose tau ID is not used
        self.update(TauID_config)

        JEC_config = sJEC.JEC(
            nickname
        )  #Is allready in baseconfig, for now leave it in; possibly remove it
        self.update(JEC_config)

        JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
        self.update(JECUncertaintySplit_config)

        JetID_config = sJID.Jet_ID(nickname)
        self.update(JetID_config)

        BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
        self.update(BTaggedJet_config)

        Svfit_config = sSvfit.Svfit(nickname)
        self.update(Svfit_config)

        MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
        MinimalPlotlevelFilter_config.tt()
        self.update(MinimalPlotlevelFilter_config)

        MVATestMethods_config = sMVATM.MVATestMethods()
        self.update(MVATestMethods_config)

        TauES_config = sTES.TauES(nickname)
        self.update(TauES_config)

        TauPolarisationMva_config = sTPMVA.TauPolarisationMva()
        self.update(TauPolarisationMva_config)

        self["TauPolarisationTmvaWeights"] = [
            "/afs/cern.ch/user/m/mfackeld/public/weights_tmva/training.weights.xml",
            "/afs/cern.ch/user/m/mfackeld/public/weights_sklearn/training_tt.weights.xml"
        ]

        self["Channel"] = "TT"
        self["MinNTaus"] = 2
        self["TauID"] = "TauIDRecommendation13TeV"
        self["TauUseOldDMs"] = True
        self["TauLowerPtCuts"] = ["40.0"]  #in json with default
        self["TauUpperAbsEtaCuts"] = ["2.1"]  #in json with default
        self["DiTauPairMinDeltaRCut"] = 0.5
        self["DiTauPairIsTauIsoMVA"] = True
        self["EventWeight"] = "eventWeight"
        self[
            "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
        if isEmbedded:
            self[
                "EmbeddingWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_11_embedded.root"

            self["EmbeddingWeightWorkspaceWeightNames"] = [
                "0:triggerWeight_doublemu", "0:triggerWeight_tau",
                "1:triggerWeight_tau"
            ]
            self["EmbeddingWeightWorkspaceObjectNames"] = [
                "0:m_sel_trg_ratio", "0:t_TightIso_tt_emb_ratio",
                "1:t_TightIso_tt_emb_ratio"
            ]
            self["EmbeddingWeightWorkspaceObjectArguments"] = [
                "0:gt1_pt,gt1_eta,gt2_pt,gt2_eta", "0:t_pt,t_dm", "1:t_pt,t_dm"
            ]
        else:
            self[
                "TauTauTriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"

            self["TauTauTriggerWeightWorkspaceWeightNames"] = [
                "0:triggerWeight", "1:triggerWeight"
            ]
            self["TauTauTriggerWeightWorkspaceObjectNames"] = [
                "0:t_genuine_TightIso_tt_ratio,t_fake_TightIso_tt_ratio",
                "1:t_genuine_TightIso_tt_ratio,t_fake_TightIso_tt_ratio"
            ]
            self["TauTauTriggerWeightWorkspaceObjectArguments"] = [
                "0:t_pt,t_dm", "1:t_pt,t_dm"
            ]
            self["EleTauFakeRateWeightFile"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root",
                "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
            ]

        if re.search("Run2016|Spring16|Summer16|Embedding2016", nickname):
            #settings for jetstotaufakesproducer
            self[
                "FakeFaktorFile"] = "root://grid-vo-cms.physik.rwth-aachen.de:1094//store/user/jdegens/higgs-kit/ff/2016/tt/fakeFactors_tt_inclusive.root"
            self["FakeFactorMethod"] = "cp2016"
            self["FakeFactorRooWorkspaceFunction"] = [
                "w_fracs_1:w_tt_fracs_1", "qcd_fracs_1:qcd_tt_fracs_1",
                "ttbar_fracs_1:ttbar_tt_fracs_1", "dy_fracs_1:dy_tt_fracs_1",
                "w_fracs_2:w_tt_fracs_2", "qcd_fracs_2:qcd_tt_fracs_2",
                "ttbar_fracs_2:ttbar_tt_fracs_2", "dy_fracs_2:dy_tt_fracs_2"
            ]
            self[
                "FakeFactorFractionsRooWorkspaceFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/rooworkspacefractions/ff_fracs_new_2016.root"

        self["TauTauRestFrameReco"] = "collinear_approximation"
        self["TriggerObjectLowerPtCut"] = 28.0
        self["InvalidateNonMatchingElectrons"] = False
        self["InvalidateNonMatchingMuons"] = False
        self["InvalidateNonMatchingTaus"] = True
        self["InvalidateNonMatchingJets"] = False
        self[
            "UseUWGenMatching"] = "true"  #TODO change this to boolean? or change the rest to string?
        self["DirectIso"] = True
        self["TopPtReweightingStrategy"] = "Run2"  #FIXME this looks more right

        self["OSChargeLeptons"] = True
        self["SvfitKappaParameter"] = 5.0

        self["AddGenMatchedTaus"] = True
        self["AddGenMatchedTauJets"] = True
        self["BranchGenMatchedTaus"] = True

        self["Consumers"] = [
            "KappaLambdaNtupleConsumer", "cutflow_histogram",
            "SvfitCacheConsumer"
        ]  #,
        #"CutFlowTreeConsumer",
        #"KappaTausConsumer",
        #"KappaTaggedJetsConsumer",
        #"RunTimeConsumer",
        #"PrintEventsConsumer",
        #"PrintGenParticleDecayTreeConsumer"]

        if re.search("Embedding", nickname):
            self["NoHltFiltering"] = True
            self["DiTauPairNoHLT"] = True
        else:
            self["NoHltFiltering"] = False
            self["DiTauPairNoHLT"] = True

        #set it here and if it is something else then change it in the ifs below
        self["HltPaths"] = [
            "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg",
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg"
        ]
        self["TauTriggerFilterNames"] = [
            "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg",  #here are : in string
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"
        ]

        if "Run2016" in nickname and not "Run2016H" in nickname:
            self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg"]
            self["TauTriggerFilterNames"] = [
                "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg"
            ]

        elif "Run2016H" in nickname:
            self["HltPaths"] = [
                "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg"
            ]
            self["TauTriggerFilterNames"] = [
                "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"
            ]

        elif "Fall15MiniAODv2" in nickname or "Run2015D" in nickname or "Embedding2015" in nickname:
            self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg"]
            self["TauTriggerFilterNames"] = [
                "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg"
            ]

        elif "Embedding2016" in nickname or "EmbeddingMC" in nickname:  #TODO Ask thomas what it should be line 40 in json
            self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v"]
            self["TauTriggerFilterNames"] = [
                "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35Reg"
            ]

        #Quantities, this looks for tt em mt et very similar, check if it is the same and if so put it in baseconfig for all channels
        quantities_dict = quantities.quantities()
        quantities_dict.build_quantities(nickname, channel=self["Channel"])

        #put rest of quantities in CPQuantities.py?

        quantities_dict["Quantities"] += [
            "nLooseElectrons", "nLooseMuons", "nDiTauPairCandidates",
            "nAllDiTauPairCandidates"
        ]
        if re.search("(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16))",
                     nickname):
            # quantities_dict["Quantities"] += quantities_dict.lheWeightsDYQuantities()
            quantities_dict["Quantities"] += [
                "tauSpinnerValidOutputs",
                "tauSpinnerPolarisation",
            ]
        elif re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):
            quantities_dict["Quantities"] += [
                "tauSpinnerValidOutputs",
                "tauSpinnerPolarisation",
            ]
        elif re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):
            quantities_dict[
                "Quantities"] += quantities_dict.genMatchedCPQuantities()
        elif re.search("Embedding2016", nickname):
            quantities_dict["Quantities"] += [
                # "tauSpinnerValidOutputs",
                # "tauSpinnerPolarisation",
                "triggerWeight_doublemu_1",
                "triggerWeight_tau_1",
                "triggerWeight_tau_2"
            ]

        self.update(copy.deepcopy(quantities_dict))

        #Producers and filters, TODO filter everything which is the same and use this as the startint list, then just add the other variables per sample

        self["Processors"] = [
            "producer:HltProducer",
            "filter:HltFilter",
            "producer:MetSelector",
            ################## special for each channel in et mt tt em.
            "producer:ValidTausProducer",
            "filter:ValidTausFilter",
            "producer:TauTriggerMatchingProducer",
            "filter:MinTausCountFilter",
            "producer:ValidElectronsProducer",
            "producer:ValidMuonsProducer",
            "producer:ValidTTPairCandidatesProducer",
            "filter:ValidDiTauPairCandidatesFilter",
            "producer:HttValidLooseElectronsProducer",
            "producer:HttValidLooseMuonsProducer",
            ##################
            "producer:Run2DecayChannelProducer",
            "producer:TaggedJetCorrectionsProducer",
            "producer:ValidTaggedJetsProducer",
            "producer:ValidBTaggedJetsProducer",
            "producer:TauTauRestFrameSelector",
            "producer:DiLeptonQuantitiesProducer",
            "producer:DiJetQuantitiesProducer",
        ]

        if re.search("(Spring16|Summer16|Run2016|Embedding2016)", nickname):
            self["Processors"] += ["producer:RefitVertexSelector"]
            self["Processors"] += ["producer:RecoTauCPProducer"]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitProducer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitM91Producer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSimpleFitProducer"
            ]
            self["Processors"] += [
                "producer:TaggedJetUncertaintyShiftProducer"
            ]
            self["Processors"] += ["producer:MetFilterProducer"]

            if re.search("(Run2016|Embedding2016)", nickname):
                #self["Processors"] += ["producer:MVATestMethodsProducer"]

                self["Processors"] += ["producer:SimpleFitProducer"]
                #self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

                self["Processors"] += ["filter:MinimalPlotlevelFilter"]
                self["Processors"] += ["producer:SvfitProducer"]
                self["Processors"] += ["producer:SvfitM91Producer"]
                #				self["Processors"] += ["producer:SvfitM125Producer"]

                self["Processors"] += ["producer:MELAProducer"]
                #				self["Processors"] += ["producer:MELAM125Producer"]

                self["Processors"] += ["producer:JetToTauFakesProducer"
                                       ]  #TODO check if only needed in data

                #self["Processors"] += ["producer:TauPolarisationTmvaReader"]

                if re.search("Embedding2016", nickname):
                    self["Processors"] += [
                        "producer:RooWorkspaceWeightProducer"
                    ]
                    self["Processors"] += ["producer:TauCorrectionsProducer"]
                    self["Processors"] += ["producer:EmbeddingWeightProducer"]

            else:
                self["Processors"] += ["producer:TauCorrectionsProducer"]
                self["Processors"] += ["producer:TauTauTriggerWeightProducer"]
                self["Processors"] += ["producer:MetCorrector"]
                self["Processors"] += [
                    "producer:SimpleEleTauFakeRateWeightProducer",
                    "producer:SimpleMuTauFakeRateWeightProducer"
                ]

                if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
                    self["Processors"] += [
                        "producer:ZPtReweightProducer"
                        #"filter:MinimalPlotlevelFilter"
                    ]
                    self["Processors"] += ["producer:GenMatchedTauCPProducer"]

                else:
                    self["Processors"] += ["filter:MinimalPlotlevelFilter"]
                    self["Processors"] += ["producer:SvfitProducer"]
                    self["Processors"] += ["producer:SvfitM91Producer"]
                    #					self["Processors"] += ["producer:SvfitM125Producer"]

                    self["Processors"] += ["producer:MELAProducer"]
                    #					self["Processors"] += ["producer:MELAM125Producer"]

                    if re.search(
                            "(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16))",
                            nickname):
                        self["Processors"] += [
                            "producer:JetToTauFakesProducer"
                        ]  #TODO also needed for mc to -
                        self["Processors"] += ["producer:ZPtReweightProducer"]

                        self["Processors"] += ["producer:SimpleFitProducer"]
                        self["Processors"] += [
                            "producer:GenMatchedTauCPProducer"
                        ]
                        self["Processors"] += [
                            "producer:GenMatchedPolarisationQuantitiesProducer"
                        ]

                        #self["Processors"] += ["producer:TauPolarisationTmvaReader"]

                    elif re.search(
                            "(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))",
                            nickname):
                        self["Processors"] += [
                            "producer:TopPtReweightingProducer"
                        ]
                        #self["Processors"] += ["producer:MVATestMethodsProducer"]
                        self["Processors"] += [
                            "producer:GenMatchedTauCPProducer"
                        ]
                        self["Processors"] += [
                            "producer:GenMatchedPolarisationQuantitiesProducer"
                        ]
                        #self["Processors"] += ["producer:TauPolarisationTmvaReader"]
                        #self["Processors"] += ["producer:MadGraphReweightingProducer"]
                    else:
                        self["Processors"] += [
                            "producer:JetToTauFakesProducer"
                        ]  #TODO Also needed for MC to -
                        self["Processors"] += [
                            "producer:TopPtReweightingProducer"
                        ]
                        #self["Processors"] += ["producer:MVATestMethodsProducer"]
                        self["Processors"] += ["producer:SimpleFitProducer"]
                        self["Processors"] += [
                            "producer:GenMatchedPolarisationQuantitiesProducer"
                        ]

                        #self["Processors"] += ["producer:TauPolarisationTmvaReader"]

        elif re.search("(Fall15|Run2015)", nickname):
            #self["Processors"] += ["producer:RefitVertexSelector"]
            self["Processors"] += ["producer:RecoTauCPProducer"]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitProducer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitM91Producer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSimpleFitProducer"
            ]
            self["Processors"] += ["filter:MinimalPlotlevelFilter"]
            self["Processors"] += ["producer:MvaMetSelector"]

            if re.search("Run2015", nickname):
                #self["Processors"] += ["producer:SimpleFitProducer"]
                self["Processors"] += [
                    "producer:GenMatchedPolarisationQuantitiesProducer"
                ]

                #self["Processors"] += ["producer:SvfitProducer"]
                #self["Processors"] += ["producer:SvfitM91Producer"]
                #self["Processors"] += ["producer:SvfitM125Producer"]

                #self["Processors"] += ["producer:MELAProducer"]
                #self["Processors"] += ["producer:MELAM125Producer"]

            else:
                self["Processors"] += ["producer:MvaMetCorrector"]
                self["Processors"] += ["producer:MetCorrector"]
                self["Processors"] += ["producer:TauCorrectionsProducer"]
                self["Processors"] += ["producer:EleTauFakeRateWeightProducer"]

                if re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):

                    self["Processors"] += ["producer:ZPtReweightProducer"]
                    #self["Processors"] += ["producer:SimpleFitProducer"]
                    self["Processors"] += ["producer:GenMatchedTauCPProducer"]
                    self["Processors"] += [
                        "producer:GenMatchedPolarisationQuantitiesProducer"
                    ]

                elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",
                               nickname):
                    self["Processors"] += ["producer:SvfitProducer"]
                    self["Processors"] += ["producer:SvfitM91Producer"]
                    #					self["Processors"] += ["producer:SvfitM125Producer"]

                    self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

                elif re.search(
                        "^((?!(DY.?JetsTo(LL|TauTau)|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15",
                        nickname):
                    self["Processors"] += ["producer:SvfitProducer"]
                    self["Processors"] += ["producer:SvfitM91Producer"]
                    #					self["Processors"] += ["producer:SvfitM125Producer"]

                    self["Processors"] += ["producer:MELAProducer"]


#					self["Processors"] += ["producer:MELAM125Producer"]

        self["Processors"] += ["producer:EventWeightProducer"]
        self["Processors"] = list(set(self["Processors"]))
        processorOrderingkey = processorOrdering.processors_ordered(
            channel=self["Channel"])
        ordered_processors = processorOrderingkey.order_processors(
            self["Processors"])
        self["Processors"] = copy.deepcopy(ordered_processors)
Exemple #16
0
# if possible, run2 configs import the run1 configs and add some extra information
## ------------------------------------------------------------------------

# Kappa test: CMSSW 7.6.3, 8.0.20
# Kappa test: scram arch slc6_amd64_gcc493, slc6_amd64_gcc530
# Kappa test: checkout script scripts/checkoutCmssw76xPackagesForSkimming.py, scripts/checkoutCmssw80xPackagesForSkimming.py
# Kappa test: output kappaTuple.root
import sys
if not hasattr(sys, 'argv'):
    sys.argv = ["cmsRun", "runFrameworkMC.py"]

import os
import FWCore.ParameterSet.Config as cms
from Kappa.Skimming.datasetsHelperTwopz import datasetsHelperTwopz
datasetsHelper = datasetsHelperTwopz(
    os.path.join(os.environ.get("CMSSW_BASE"),
                 "src/Kappa/Skimming/data/datasets.json"))
import Kappa.Skimming.tools as tools

from FWCore.ParameterSet.VarParsing import VarParsing
options = VarParsing('python')
options.register('nickname', '', VarParsing.multiplicity.singleton,
                 VarParsing.varType.string, 'Dataset Nickname')
options.register(
    'testfile', '', VarParsing.multiplicity.singleton,
    VarParsing.varType.string,
    'Path for a testfile. If no test file is given, nickname is used to get a test file with xrootd.'
)
options.register('maxevents', -1, VarParsing.multiplicity.singleton,
                 VarParsing.varType.int,
                 'maxevents. -1 for all events. Default: -1')
	def build_config(self, nickname, *args, **kwargs): #Maybe change this the arguments to process/year and DATA/MC

		datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

		# define frequently used conditions
		isEmbedded = datasetsHelper.isEmbedded(nickname)
		isData = datasetsHelper.isData(nickname) and (not isEmbedded)

		ElectronID_config = sEID.Electron_ID(nickname)
		ElectronID_config.looseElectron_ID(nickname) 		#append the config for loose electron ID because it is used
		self.update(ElectronID_config)

		MuonID_config = sMID.Muon_ID(nickname)
		MuonID_config.looseMuon_ID(nickname) 		#append the config for loose Muon ID because it is used
		self.update(MuonID_config)

		TauID_config = sTID.Tau_ID(nickname)			#here loose is not appended since loose tau ID is not used
		self.update(TauID_config)

		JEC_config = sJEC.JEC(nickname)  #Is allready in baseconfig, for now leave it in; possibly remove it
		self.update(JEC_config)

		JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
		self.update(JECUncertaintySplit_config)

		JetID_config = sJID.Jet_ID(nickname)
		self.update(JetID_config)

		BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
		self.update(BTaggedJet_config)

		Svfit_config = sSvfit.Svfit(nickname)
		self.update(Svfit_config)

		MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
		MinimalPlotlevelFilter_config.em()
		self.update(MinimalPlotlevelFilter_config)
		
		MVATestMethods_config = sMVATM.MVATestMethods()
		self.update(MVATestMethods_config)

		self["Channel"] = "EM"
		self["MinNElectrons"] = 1
		self["MinNMuons"] = 1
		self["HltPaths_comment"] = "The first path must be one with the higher pt cut on the electron. The second and last path must be one with the higher pt cut on the muon. Corresponding Pt cuts are implemented in the Run2DecayChannelProducer."

		self["NoHltFiltering"] = False #*default
		self["DiTauPairLepton1LowerPtCuts"] = [								     # **default
			"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:24.0"
		]

		self["DiTauPairLepton2LowerPtCuts"] = [								# ***default
			"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:24.0",
			"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
		]
		self["DiTauPairNoHLT"] = False
		
		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["HltPaths"] = [
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL",
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
			]
			self["DiTauPairLepton1LowerPtCuts"] = [							#**
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:18.0"
			]
			self["DiTauPairLepton2LowerPtCuts"] = [
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL_v:18.0"
			]

		elif re.search("Run2016(B|C|D|E|F)|Spring16|Summer16", nickname):
			self["HltPaths"] = [
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
			]

		elif re.search("Run2016(G|H)", nickname):
			self["HltPaths"] = [
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ"
			]
			self["DiTauPairLepton1LowerPtCuts"] = [							#**
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
			]

		elif re.search("Embedding(2016|MC)", nickname):
			self["HltPaths"] = []
			self["NoHltFiltering"] = True 								#*if "Embedding(2016|MC)"
			self["DiTauPairLepton1LowerPtCuts"] = [                                         	 #**
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:-1.0",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:-1.0"
			]
			self["DiTauPairLepton2LowerPtCuts"] = [							#***
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:-1.0",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:-1.0"
			]
			self["DiTauPairNoHLT"] = True
			self["LowerCutHardLepPt"] = 24.0
		
		self["ElectronLowerPtCuts"] = [
			"13.0"
		]
		self["ElectronUpperAbsEtaCuts"] = [
			"2.5"
		]
		self["MuonLowerPtCuts"] = [
			"10.0"
		]
		self["MuonUpperAbsEtaCuts"] = [
			"2.4"
		]
		self["DeltaRTriggerMatchingElectrons"] = 0.4
		self["DeltaRTriggerMatchingMuons"] = 0.4
		self["DiTauPairMinDeltaRCut"] = 0.3
		self["DiTauPairIsTauIsoMVA"] = True

		self["EventWeight"] = "eventWeight"
		self["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5_1.root"
		self["RooWorkspaceWeightNames"] = [
			"0:idIsoWeight",
			"0:emuQcdOsssWeight",
			"0:emuQcdOsssRateUpWeight",
			"0:emuQcdOsssRateDownWeight",
			"0:emuQcdOsssShapeUpWeight",
			"0:emuQcdOsssShapeDownWeight",
			"0:emuQcdExtrapUpWeight",
			"0:emuQcdExtrapDownWeight",			
			"1:idIsoWeight",
			"1:emuQcdOsssWeight",
			"1:emuQcdOsssRateUpWeight",
			"1:emuQcdOsssRateDownWeight",
			"1:emuQcdOsssShapeUpWeight",
			"1:emuQcdOsssShapeDownWeight",
			"1:emuQcdExtrapUpWeight",
			"1:emuQcdExtrapDownWeight"							
		]
		self["RooWorkspaceObjectNames"] = [
			"0:e_idiso0p15_desy_ratio",
			"0:em_qcd_osss_binned",
			"0:em_qcd_osss_rateup_binned",
			"0:em_qcd_osss_ratedown_binned",
			"0:em_qcd_osss_shapeup_binned",
			"0:em_qcd_osss_shapedown_binned",
			"0:em_qcd_extrap_up",
			"0:em_qcd_extrap_down",			
			"1:m_idiso0p20_desy_ratio",
			"1:em_qcd_osss_binned",
			"1:em_qcd_osss_rateup_binned",
			"1:em_qcd_osss_ratedown_binned",
			"1:em_qcd_osss_shapeup_binned",
			"1:em_qcd_osss_shapedown_binned",
			"1:em_qcd_extrap_up",
			"1:em_qcd_extrap_down",				
		]
		self["RooWorkspaceObjectArguments"] = [
			"0:e_pt,e_eta",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"1:m_pt,m_eta",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt"
		]

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["TriggerEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Electron_Ele12_fall15.root",         	 #2 times 0:... and 1:...
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Electron_Ele17_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Muon_Mu8_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Muon_Mu17_fall15.root"
			]

			self["TriggerEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele12_fall15.root",
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele17_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu8_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu17_fall15.root"
			]

			self["IdentificationEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p15_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
			]
			self["IdentificationEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso0p15_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso0p15_fall15.root"
			]

		else:
			self["TriggerEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele12leg_eff.root",      		 #2 times 0:... and 1:...
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele23leg_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu8leg_2016BtoH_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu23leg_2016BtoH_eff.root"
			]
			self["TriggerEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele12leg_eff.root",
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele23leg_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu8leg_2016BtoH_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu23leg_2016BtoH_eff.root"
			]
		
			self["IdentificationEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p15_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
			]
			self["IdentificationEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p15_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
			]

		self["TriggerEfficiencyMode"] = "correlate_triggers"
		self["IdentificationEfficiencyMode"] = "multiply_weights"
		self["TauTauRestFrameReco"] = "collinear_approximation"

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["ElectronTriggerFilterNames"] = [
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu17TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle17CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter"
			]
			self["MuonTriggerFilterNames"] = [
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu17TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered17",
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle17CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8"
			]

		elif re.search("Run2016(B|C|D|E|F)|Spring16|Summer16", nickname):
			self["ElectronTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter"
			]
			self["MuonTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8"
			]

		elif re.search("Run2016(G|H)", nickname):
			self["ElectronTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLDZFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLDZFilter"
			]
			self["MuonTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLDZFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLDZFilter"
			]

		self["InvalidateNonMatchingElectrons"] = True
		self["InvalidateNonMatchingMuons"] = True
		self["InvalidateNonMatchingTaus"] = False
		self["InvalidateNonMatchingJets"] = False
		self["DirectIso"] = True
	
		self["OSChargeLeptons"] = True
		self["SvfitKappaParameter"] = 3.0

		self["AddGenMatchedParticles"] = True
		self["BranchGenMatchedElectrons"] = True
		self["BranchGenMatchedMuons"] = True
		self["Consumers"] = [
			"KappaLambdaNtupleConsumer",
			"cutflow_histogram",
			"SvfitCacheConsumer",
			"#CutFlowTreeConsumer",
			"#KappaElectronsConsumer",
			"#KappaMuonsConsumer",
			"#KappaTaggedJetsConsumer",
			"#RunTimeConsumer",
			"#PrintEventsConsumer",
			"#PrintGenParticleDecayTreeConsumer"
		]

		quantities_dict = quantities.quantities() 
		quantities_dict.build_quantities(nickname, channel = self["Channel"])

		#put rest of quantities in CPQuantities.py?

		quantities_dict["Quantities"] += [
				"nLooseElectrons",
				"nLooseMuons",
				"nDiTauPairCandidates",
				"nAllDiTauPairCandidates"
			]

		if re.search("(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16))", nickname):
			# quantities_dict["Quantities"] += quantities_dict.lheWeightsDYQuantities()
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += quantities_dict.svfitSyncQuantities()
		elif re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("Embedding2016", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += [
				"jetCorrectionWeight"
			]
		self.update(copy.deepcopy(quantities_dict))

		self["Processors"] = [
				"producer:HltProducer",
				"filter:HltFilter",
				"producer:MetSelector",
				################## special for each channel in et mt tt em.
				"producer:ValidElectronsProducer",
				"filter:ValidElectronsFilter",
				"producer:ElectronTriggerMatchingProducer",
				"filter:MinElectronsCountFilter",
				"producer:ValidMuonsProducer",
				"filter:ValidMuonsFilter",
				"producer:MuonTriggerMatchingProducer",
				"filter:MinMuonsCountFilter",
				"producer:ValidTausProducer",
				"producer:ValidEMPairCandidatesProducer",
				"filter:ValidDiTauPairCandidatesFilter",
				"producer:HttValidLooseMuonsProducer",
				##################
				"producer:Run2DecayChannelProducer",          
				"producer:TaggedJetCorrectionsProducer",
				"producer:ValidTaggedJetsProducer",
				"producer:ValidBTaggedJetsProducer",	
				"producer:TauTauRestFrameSelector",
				"producer:DiLeptonQuantitiesProducer",
				"producer:DiJetQuantitiesProducer",
				"producer:HttValidLooseElectronsProducer"
				]

		if re.search("(Spring16|Summer16|Run2016)", nickname):
			self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["producer:TaggedJetUncertaintyShiftProducer"]
			self["Processors"]+= ["producer:MetFilterProducer"]
			
			if re.search("Run2016", nickname):
				#self["Processors"] += ["producer:MVATestMethodsProducer"]
						
				self["Processors"] += ["producer:SimpleFitProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				self["Processors"] += ["filter:MinimalPlotlevelFilter"]
				self["Processors"] += ["producer:SvfitProducer"]
				self["Processors"] += ["producer:SvfitM91Producer"]
#				self["Processors"] += ["producer:SvfitM125Producer"]

				self["Processors"] += ["producer:MELAProducer"]
#				self["Processors"] += ["producer:MELAM125Producer"]


				#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

			else:
				#self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:ElectronCorrectionsProducer"] #channel dependent
				self["Processors"] += ["producer:TriggerWeightProducer"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:RooWorkspaceWeightProducer"]
							
				if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
					self["Processors"] += [
						"producer:ZPtReweightProducer"
						#"filter:MinimalPlotlevelFilter"
					]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:LFVJetCorrection2016Producer"]

				else:              
					self["Processors"] += ["filter:MinimalPlotlevelFilter"]
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
#					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

					if re.search("(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += ["producer:ZPtReweightProducer"]			

						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

					elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += [
							"producer:TopPtReweightingProducer"
						] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
						#self["Processors"] += ["producer:MadGraphReweightingProducer"]
					else:
						self["Processors"] += [	"producer:TopPtReweightingProducer"] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:SimpleFitProducer"]				
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
				
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

		elif re.search("(Fall15|Run2015)", nickname):
			#self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["filter:MinimalPlotlevelFilter"]
			self["Processors"] += ["producer:MvaMetSelector"]

			
			if re.search("Run2015", nickname):
				pass
				#self["Processors"] += ["producer:SimpleFitProducer"]
			
				#self["Processors"] += ["producer:SvfitProducer"]
				#self["Processors"] += ["producer:SvfitM91Producer"]
				#self["Processors"] += ["producer:SvfitM125Producer"]

				#self["Processors"] += ["producer:MELAProducer"]
				#self["Processors"] += ["producer:MELAM125Producer"]
			else:
				self["Processors"] += ["producer:MvaMetCorrector"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:RecoElectronGenParticleMatchingProducer"] #if you grep this, it is already in globalprocessors
				self["Processors"] += ["producer:RecoMuonGenParticleMatchingProducer"]
				self["Processors"] += ["producer:MatchedLeptonsProducer"]
				#self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:TriggerWeightProducer",
					"producer:IdentificationWeightProducer",
					"producer:EleTauFakeRateWeightProducer"
				]

				if re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):

					self["Processors"] += ["producer:ZPtReweightProducer"]			
					#self["Processors"] += ["producer:SimpleFitProducer"]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
#					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

				elif re.search("^((?!(DY.?JetsTo(LL|TauTau)|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
#					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

		self["Processors"] += ["producer:EventWeightProducer"]
		self["Processors"] = list(set(self["Processors"]))
		processorOrderingkey = processorOrdering.processors_ordered(channel = self["Channel"])
		ordered_processors = processorOrderingkey.order_processors(self["Processors"]) 
		self["Processors"] = copy.deepcopy(ordered_processors)
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    #isTTbar = re.search("TT(To|_|Jets)", nickname)
    #isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    #isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = []
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["nominal"] = {"JetEnergyCorrectionUncertaintyShift": [0.0]}

    if isEmbedded:
        config["muonEsUp"] = {"JetEnergyCorrectionUncertaintyShift": [0.0]}
        config["muonEsUp"]["MuonEnergyCorrectionShift"] = 1.004

        config["muonEsDown"] = {"JetEnergyCorrectionUncertaintyShift": [0.0]}
        config["muonEsDown"]["MuonEnergyCorrectionShift"] = 0.996

    if not isData:
        config["tauEsOneProngUp"] = {
            "JetEnergyCorrectionUncertaintyShift": [0.0]
        }
        config["tauEsOneProngUp"]["TauEnergyCorrectionOneProng"] = 1.007

        config["tauEsOneProngDown"] = {
            "JetEnergyCorrectionUncertaintyShift": [0.0]
        }
        config["tauEsOneProngDown"]["TauEnergyCorrectionOneProng"] = 0.983

        config["tauEsOneProngOnePiZeroUp"] = {
            "JetEnergyCorrectionUncertaintyShift": [0.0]
        }
        config["tauEsOneProngOnePiZeroUp"][
            "TauEnergyCorrectionOneProngPiZeros"] = 1.023

        config["tauEsOneProngOnePiZeroDown"] = {
            "JetEnergyCorrectionUncertaintyShift": [0.0]
        }
        config["tauEsOneProngOnePiZeroDown"][
            "TauEnergyCorrectionOneProngPiZeros"] = 0.999

        config["tauEsThreeProngUp"] = {
            "JetEnergyCorrectionUncertaintyShift": [0.0]
        }
        config["tauEsThreeProngUp"]["TauEnergyCorrectionThreeProng"] = 1.018

        config["tauEsThreeProngDown"] = {
            "JetEnergyCorrectionUncertaintyShift": [0.0]
        }
        config["tauEsThreeProngDown"]["TauEnergyCorrectionThreeProng"] = 0.994

    return config
Exemple #19
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("(DY.?JetsToLL|EWKZ2Jets)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJEC",
        #"HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJECUncertaintySplit",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_tt",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsSvfit",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsTauES",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsMVATestMethods"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "TT"
    config["MinNTaus"] = 2
    # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
    if re.search("Run2016(B|C|D|E|F|G)", nickname):
        config["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg"]
        config["HLTBranchNames"] = [
            "trg_doubletau:HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v"
        ]
    elif re.search("Run2016H", nickname):
        config["HltPaths"] = [
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg"
        ]
        config["HLTBranchNames"] = [
            "trg_doubletau:HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v"
        ]
    elif isEmbedded:
        config["HltPaths"] = [""]
    else:
        config["HltPaths"] = [
            "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg",
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg"
        ]
        config["HLTBranchNames"] = [
            "trg_doubletau:HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v",
            "trg_doubletau:HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v"
        ]

    config["NoHltFiltering"] = True if isEmbedded else False
    config["TauID"] = "TauIDRecommendation13TeV"
    config["TauUseOldDMs"] = True
    config["TauLowerPtCuts"] = ["40.0"]
    config["TauUpperAbsEtaCuts"] = ["2.1"]
    config["DiTauPairLepton1LowerPtCuts"] = [
        "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg:40.0",
        "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg:40.0"
    ]
    config["DiTauPairLepton2LowerPtCuts"] = [
        "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg:40.0",
        "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg:40.0"
    ]
    config["DiTauPairMinDeltaRCut"] = 0.5
    config["DiTauPairIsTauIsoMVA"] = True
    config["DiTauPairNoHLT"] = True if isEmbedded else True
    config["DiTauPairHLTLast"] = False
    config["EventWeight"] = "eventWeight"
    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
    config[
        "TauTauTriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
    config["TauTauTriggerWeightWorkspaceWeightNames"] = [
        "0:triggerWeight", "1:triggerWeight"
    ]
    config["TauTauTriggerWeightWorkspaceObjectNames"] = [
        "0:t_genuine_TightIso_tt_ratio,t_fake_TightIso_tt_ratio",
        "1:t_genuine_TightIso_tt_ratio,t_fake_TightIso_tt_ratio"
    ]
    config["TauTauTriggerWeightWorkspaceObjectArguments"] = [
        "0:t_pt,t_dm", "1:t_pt,t_dm"
    ]
    config["EleTauFakeRateWeightFile"] = [
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
    ]
    config["TauTauRestFrameReco"] = "collinear_approximation"

    if re.search("Run2016(B|C|D|E|F|G)", nickname):
        config["TauTriggerFilterNames"] = [
            "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg"
        ]
    elif re.search("Run2016H", nickname):
        config["TauTriggerFilterNames"] = [
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"
        ]
    else:
        config["TauTriggerFilterNames"] = [
            "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg",
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"
        ]

    config["TriggerObjectLowerPtCut"] = 28.0
    config["InvalidateNonMatchingElectrons"] = False
    config["InvalidateNonMatchingMuons"] = False
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True
    config["UseUWGenMatching"] = "true"

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.fourVectorQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.syncQuantities"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.svfitSyncQuantities"
        ).build_list())
    #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.splitJecUncertaintyQuantities").build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    config["Quantities"].extend([
        "nLooseElectrons",
        "nLooseMuons",
        "nDiTauPairCandidates",
        "nAllDiTauPairCandidates",
        "trg_doubletau",
        "lep1ErrD0",
        "lep1ErrDz",
        "lep2ErrD0",
        "lep2ErrDz",
        "PVnDOF",
        #"PVchi2",
        "drel0_1",
        "drel0_2",
        "drelZ_1",
        "drelZ_2",
        #"htxs_stage0cat",
        #"htxs_stage1cat",
        "flagMETFilter"
    ])
    if re.search("HToTauTauM125", nickname):
        config["Quantities"].extend(["htxs_stage0cat", "htxs_stage1cat"])

    config["OSChargeLeptons"] = True

    config["Processors"] = [
        "producer:HltProducer", "filter:HltFilter", "producer:MetSelector"
    ]
    if not isData:
        config["Processors"].append("producer:TauCorrectionsProducer")
    config["Processors"].extend(
        ("producer:ValidTausProducer", "filter:ValidTausFilter",
         "producer:TauTriggerMatchingProducer", "filter:MinTausCountFilter",
         "producer:ValidElectronsProducer", "producer:ValidMuonsProducer",
         "producer:ValidTTPairCandidatesProducer",
         "filter:ValidDiTauPairCandidatesFilter",
         "producer:HttValidLooseElectronsProducer",
         "producer:HttValidLooseMuonsProducer",
         "producer:Run2DecayChannelProducer",
         "producer:TaggedJetCorrectionsProducer",
         "producer:ValidTaggedJetsProducer",
         "producer:ValidBTaggedJetsProducer"))
    #"producer:TaggedJetUncertaintyShiftProducer"))
    if not isData:
        config["Processors"].append(
            "producer:MetCorrector")  #"producer:MvaMetCorrector"
    config["Processors"].extend(("producer:TauTauRestFrameSelector",
                                 "producer:DiLeptonQuantitiesProducer",
                                 "producer:DiJetQuantitiesProducer"))
    if not (isData or isEmbedded):
        config["Processors"].extend(
            ("producer:SimpleEleTauFakeRateWeightProducer",
             "producer:SimpleMuTauFakeRateWeightProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    if isDY: config["Processors"].append("producer:ZPtReweightProducer")
    config["Processors"].extend(
        ("filter:MinimalPlotlevelFilter", "producer:SvfitProducer",
         "producer:ImpactParameterCorrectionsProducer"
         ))  #"producer:MVATestMethodsProducer"
    if not isData:
        config["Processors"].append("producer:TauTauTriggerWeightProducer")
    config["Processors"].append("producer:EventWeightProducer")

    config["AddGenMatchedTaus"] = True
    config["AddGenMatchedTauJets"] = True
    config["BranchGenMatchedTaus"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer", "cutflow_histogram"]
    #"SvfitCacheConsumer"]
    #"CutFlowTreeConsumer",
    #"KappaElectronsConsumer",
    #"KappaTausConsumer",
    #"KappaTaggedJetsConsumer",
    #"RunTimeConsumer",
    #"PrintEventsConsumer"

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs('tt', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.nominal").build_config(nickname)) + \
           ACU.apply_uncertainty_shift_configs('tt', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.JECunc_shifts").build_config(nickname)) + \
           ACU.apply_uncertainty_shift_configs('tt', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.METunc_shifts").build_config(nickname)) + \
           ACU.apply_uncertainty_shift_configs('tt', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.tauESperDM_shifts").build_config(nickname)) + \
           ACU.apply_uncertainty_shift_configs('tt', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.tauJetFakeESIncl_shifts").build_config(nickname)) + \
           ACU.apply_uncertainty_shift_configs('tt', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.btagging_shifts").build_config(nickname))
	def build_config(self, nickname, *args, **kwargs): #Maybe change this the arguments to process/year and DATA/MC
		"""
		"include" : [
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsVetoElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJEC.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJECUncertaintySplit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsBTaggedJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsSvfit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMinimalPlotlevelFilter_et.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Includes/settingsMVATestMethods.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauES.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2CPStudies/Includes/settingsTauPolarisationMva.json"
		],
		"""

		datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

		# define frequently used conditions
		isEmbedded = datasetsHelper.isEmbedded(nickname)
		isData = datasetsHelper.isData(nickname) and (not isEmbedded)

		ElectronID_config = sEID.Electron_ID(nickname)
		ElectronID_config.looseElectron_ID(nickname) 		#append the config for loose electron ID because it is used
		ElectronID_config.vetoElectron_ID(nickname)
		self.update(ElectronID_config)

		MuonID_config = sMID.Muon_ID(nickname)
		MuonID_config.looseMuon_ID(nickname) 		#append the config for loose Muon ID because it is used

		self.update(MuonID_config)

		TauID_config = sTID.Tau_ID(nickname)			#here loose is not appended since loose tau ID is not used
		self.update(TauID_config)

		JEC_config = sJEC.JEC(nickname)  #Is allready in baseconfig, for now leave it in; possibly remove it
		self.update(JEC_config)

		JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
		self.update(JECUncertaintySplit_config)

		JetID_config = sJID.Jet_ID(nickname)
		self.update(JetID_config)

		BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
		self.update(BTaggedJet_config)

		Svfit_config = sSvfit.Svfit(nickname)
		self.update(Svfit_config)

		MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
		MinimalPlotlevelFilter_config.et()
		self.update(MinimalPlotlevelFilter_config)

		MVATestMethods_config = sMVATM.MVATestMethods()
		self.update(MVATestMethods_config)

		TauES_config = sTES.TauES(nickname)
		self.update(TauES_config)

		TauPolarisationMva_config = sTPMVA.TauPolarisationMva()
		self.update(TauPolarisationMva_config)

		self["TauPolarisationTmvaWeights"] = [
			"/afs/cern.ch/user/m/mfackeld/public/weights_tmva/training.weights.xml",
			"/afs/cern.ch/user/m/mfackeld/public/weights_sklearn/training_et.weights.xml"
		]
		self["Channel"] =  "ET"
		self["MinNElectrons"] =  1
		self["MinNTaus"] =  1
		self["HltPaths_comment"] =  "The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer."

		self["NoHltFiltering"] = False  #else
		self["DiTauPairNoHLT" ] = False

		self["ElectronLowerPtCuts"] = ["26.0"]  #default: !=2015
		self["DiTauPairLepton1LowerPtCuts"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v:26.0"]  #default: !=2015 or !=2017

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["HltPaths"] = ["HLT_Ele23_WPLoose_Gsf"]
			self["ElectronLowerPtCuts"] = ["24.0"]           #2015
			self["DiTauPairLepton1LowerPtCuts"] = ["HLT_Ele23_WPLoose_Gsf_v:24.0"]  #2015

			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = ["HLT_Ele23_WPLoose_Gsf_v"]

		elif re.search("Run2016|Spring16|Summer16", nickname):          #spring16 self["NoHltFiltering"] = True for cp config False for RUN2 set to false here
			self["HltPaths"] = ["HLT_Ele25_eta2p1_WPTight_Gsf"]
			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v"]

		elif re.search("Embedding(2016|MC)", nickname):
			self["HltPaths"] =[""]
			self["NoHltFiltering"] = True               #else: self["NoHltFiltering"] = True
			self["DiTauPairNoHLT" ] = True

			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v"]


		elif re.search("Run2017|Summer17|Fall17", nickname):
			self["HltPaths"] = [
					"HLT_Ele35_WPTight_Gsf",
					"HLT_Ele32_WPTight_Gsf"
				]
			self["ElectronLowerPtCuts"] = [	"36.0"]
			self["DiTauPairLepton1LowerPtCuts"] = [
					"HLT_Ele35_WPTight_Gsf_v:36.0",
					"HLT_Ele32_WPTight_Gsf_v:36.0"
				]
			self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
					"HLT_Ele35_WPTight_Gsf_v",
					"HLT_Ele32_WPTight_Gsf_v"
				]

		self["TauID"] =  "TauIDRecommendation13TeV"
		self["TauUseOldDMs"] =  True

		self["ElectronUpperAbsEtaCuts"] = ["2.1"]
		self["TauLowerPtCuts"] = ["20.0"]
		self["TauUpperAbsEtaCuts"] = ["2.3"]
		self["TriggerObjectLowerPtCut"] = -1.0

		self["DiTauPairMinDeltaRCut"] = 0.5
		self["DiTauPairIsTauIsoMVA"] = True

		self["EventWeight"] =  "eventWeight"
		self["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_11_embedded.root" if isEmbedded else "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
		self["RooWorkspaceWeightNames"] = [
			"0:triggerWeight",
			"0:idIsoWeight"
		] if not isEmbedded else [
			"0:triggerWeight_doublemu",
			"0:isoweight",
			"0:idweight",
			"0:triggerWeight_singleE"
		]
		self["RooWorkspaceObjectNames"] = [
			"0:e_trgEle25eta2p1WPTight_desy_ratio",
			"0:e_idiso0p1_desy_ratio"
		] if not isEmbedded else [
			"0:m_sel_trg_ratio",
			"0:e_iso_ratio",
			"0:e_id_ratio",
			"0:e_trg_ratio"
		]
		self["RooWorkspaceObjectArguments"] = [
			"0:e_pt,e_eta",
			"0:e_pt,e_eta"
		] if not isEmbedded else [
			"0:gt1_pt,gt1_eta,gt2_pt,gt2_eta",
			"0:e_pt,e_eta",
			"0:e_pt,e_eta",
			"0:e_pt,e_eta"
		]

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["TriggerEfficiencyData"] = [ "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Electron_Ele23_fall15.root" ]
			self["TriggerEfficiencyMc"] = [ "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele23_fall15.root"]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2015_Electron_IdIso0p1_fall15.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso0p1_fall15.root"]

		elif re.search("Run2017|Summer17|Fall17", nickname):
			self["TriggerEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2017_Electron_Ele32orEle35.root"]
			self["TriggerEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MCFall2017_Electron_Ele32orEle35.root"]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2017_Electron_IdIso_IsoLt0.10_eff_RerecoFall17.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MCFall2017_Electron_IdIso_IsoLt0.10_eff_RerecoFall17.root"]

		else:
			self["TriggerEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele25WPTight_eff.root" ]
			self["TriggerEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele25WPTight_eff.root" ]

			self["IdentificationEfficiencyData"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p1_eff.root"]
			self["IdentificationEfficiencyMc"] = ["0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p1_eff.root"]

		self["TriggerEfficiencyMode"] = "multiply_weights"
		self["IdentificationEfficiencyMode"] = "multiply_weights"
		if re.search("Run2017|Summer17|Fall17", nickname):
			self["EleTauFakeRateWeightFile"] =[""]

		else:
			self["EleTauFakeRateWeightFile"] = [
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
			]
		self["TauTauRestFrameReco"] = "collinear_approximation"


		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["ElectronTriggerFilterNames"] = ["HLT_Ele23_WPLoose_Gsf_v:hltEle23WPLooseGsfTrackIsoFilter"]

		elif re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)", nickname):
			self["ElectronTriggerFilterNames"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v:hltEle25erWPTightGsfTrackIsoFilter"]

		elif re.search("Run2017|Summer17|Fall17", nickname):
			self["ElectronTriggerFilterNames"] = [
					"HLT_Ele35_WPTight_Gsf_v:hltEle35noerWPTightGsfTrackIsoFilter",
					"HLT_Ele32_WPTight_Gsf_v:hltEle32WPTightGsfTrackIsoFilter"
			]

		if re.search("Run2016|Spring16|Summer16|Embedding2016", nickname):
			#settings for jetstotaufakesproducer
			self["FakeFaktorFile"] = "root://grid-vo-cms.physik.rwth-aachen.de:1094//store/user/jdegens/higgs-kit/ff/2016/et/fakeFactors_20180831_tight.root"
			self["FakeFactorMethod"] = "cp2016"
			self["FakeFactorRooWorkspaceFunction"] = [
				"w_fracs:w_et_fracs",
				"qcd_fracs:qcd_et_fracs",
				"ttbar_fracs:ttbar_et_fracs"
			]
			self["FakeFactorFractionsRooWorkspaceFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/rooworkspacefractions/ff_fracs_new_2016.root"


		self["InvalidateNonMatchingElectrons"] = True
		self["InvalidateNonMatchingMuons"] = False
		self["InvalidateNonMatchingTaus"] = True
		self["InvalidateNonMatchingJets"] = False
		self["UseUWGenMatching"] = "true"
		self["DirectIso"] = True

		self["OSChargeLeptons"] = True
		self["SvfitKappaParameter"] = 4.0

		self["AddGenMatchedParticles"] = True
		self["AddGenMatchedTaus"] = True
		self["AddGenMatchedTauJets"] = True
		self["BranchGenMatchedElectrons"] = True
		self["BranchGenMatchedTaus"] = True
		self["Consumers"] = [
			"KappaLambdaNtupleConsumer",
			"cutflow_histogram",
			"SvfitCacheConsumer",
			"#CutFlowTreeConsumer",
			"#KappaElectronsConsumer",
			"#KappaTausConsumer",
			"#KappaTaggedJetsConsumer",
			"#RunTimeConsumer",
			"#PrintEventsConsumer",
			"#PrintGenParticleDecayTreeConsumer"
		]

		quantities_dict = quantities.quantities()
		quantities_dict.build_quantities(nickname, channel = self["Channel"])

		#put rest of quantities in CPQuantities.py?

		quantities_dict["Quantities"] += [
				"nVetoElectrons",
				"nLooseElectrons",
				"nLooseMuons",
				"nDiTauPairCandidates",
				"nAllDiTauPairCandidates"
			]

		if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16|Summer17|Fall17))", nickname):	 #the same as tt

			quantities_dict["Quantities"] += quantities_dict.genQuantities()

			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]

		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16|Summer17|Fall17))", nickname):

			quantities_dict["Quantities"] += [
				"#tauPolarisationTMVA",
				"#tauPolarisationSKLEARN",
			]

		elif re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):

			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]


		elif re.search("Embedding2016", nickname):

			quantities_dict["Quantities"] += quantities_dict.genQuantities()

			quantities_dict["Quantities"] += [
				# "tauSpinnerValidOutputs",
				# "tauSpinnerPolarisation",
				"triggerWeight_doublemu_1",
				"isoweight_1",
				"idweight_1",
				"triggerWeight_singleE_1",
			]

		elif re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += [
				"jetCorrectionWeight"
			]

		self.update(copy.deepcopy(quantities_dict))

		self["Processors"] = [
				"producer:HltProducer",
				"filter:HltFilter",
				"producer:MetSelector",
				################## special for each channel in et mt tt em.
				"producer:ValidElectronsProducer",
				"filter:ValidElectronsFilter",
				"producer:ElectronTriggerMatchingProducer",
				"filter:MinElectronsCountFilter",
				"producer:ValidMuonsProducer",
				"producer:ValidTausProducer",
				"filter:ValidTausFilter",
				"producer:TauTriggerMatchingProducer",
				"filter:MinTausCountFilter",
				"producer:ValidETPairCandidatesProducer",
				"filter:ValidDiTauPairCandidatesFilter",
				"producer:HttValidVetoElectronsProducer",
				"producer:HttValidLooseElectronsProducer",
				"producer:HttValidLooseMuonsProducer",
				"producer:DiVetoElectronVetoProducer",
				##################
				"producer:Run2DecayChannelProducer",
				"producer:TaggedJetCorrectionsProducer",
				"producer:ValidTaggedJetsProducer",
				"producer:ValidBTaggedJetsProducer",
				"producer:TauTauRestFrameSelector",
				"producer:DiLeptonQuantitiesProducer",
				"producer:DiJetQuantitiesProducer",
				]

		if re.search("(Spring16|Summer16|Run2016|Run2017|Summer17|Fall17|Embedding2016)", nickname):
			self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"]+= ["producer:MetFilterProducer"]
			if re.search("(Run2017|Summer17|Fall17)", nickname) == None:
				self["Processors"] += ["producer:TaggedJetUncertaintyShiftProducer"]

			if re.search("(Run2016|Run2017|Embedding2016)", nickname):
				#self["Processors"] += ["producer:MVATestMethodsProducer"]
				self["Processors"] += ["producer:JetToTauFakesProducer"]

				self["Processors"] += ["producer:SimpleFitProducer"]
				#self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				self["Processors"] += ["filter:MinimalPlotlevelFilter"]
				self["Processors"] += ["producer:SvfitProducer"]
				self["Processors"] += ["producer:SvfitM91Producer"]
				self["Processors"] += ["producer:SvfitM125Producer"]

				self["Processors"] += ["producer:MELAProducer"]
				self["Processors"] += ["producer:MELAM125Producer"]

				#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
				if re.search("Embedding2016", nickname):
					self["Processors"] += ["producer:RooWorkspaceWeightProducer"]  #changes from file to file
					self["Processors"] += ["producer:TauCorrectionsProducer"]

			else:
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:RooWorkspaceWeightProducer"]  #changes from file to file
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += [
						"producer:SimpleEleTauFakeRateWeightProducer",
						"producer:SimpleMuTauFakeRateWeightProducer"
						]

				if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
					self["Processors"] += [
						"producer:ZPtReweightProducer"
						#"filter:MinimalPlotlevelFilter"
					]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:LFVJetCorrection2016Producer"]

				else:
					self["Processors"] += ["filter:MinimalPlotlevelFilter"]
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

					if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16|Summer17|Fall17))", nickname):
						self["Processors"] += ["producer:JetToTauFakesProducer"]
						self["Processors"] += ["producer:ZPtReweightProducer"]

						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

					elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16|Summer17|Fall17))", nickname):
						self["Processors"] += [
							"producer:TopPtReweightingProducer"
						]
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
						#self["Processors"] += ["producer:MadGraphReweightingProducer"]
					else:
						self["Processors"] += [	"producer:TopPtReweightingProducer"]
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
						self["Processors"] += ["producer:JetToTauFakesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

		elif re.search("(Fall15|Run2015)", nickname):
			#self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["filter:MinimalPlotlevelFilter"]
			self["Processors"] += ["producer:MvaMetSelector"]


			if re.search("Run2015", nickname):
				#self["Processors"] += ["producer:SimpleFitProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				#self["Processors"] += ["producer:SvfitProducer"]
				#self["Processors"] += ["producer:SvfitM91Producer"]
				#self["Processors"] += ["producer:SvfitM125Producer"]

				#self["Processors"] += ["producer:MELAProducer"]
				#self["Processors"] += ["producer:MELAM125Producer"]
			else:

				self["Processors"] += ["producer:MvaMetCorrector"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += [
					"producer:EleTauFakeRateWeightProducer"
				]
				if re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):
					self["Processors"] += ["producer:ZPtReweightProducer"]
					#self["Processors"] += ["producer:SimpleFitProducer"]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

				elif re.search("^((?!(DY.?JetsToLL|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

		self["Processors"] += ["producer:EventWeightProducer"]
		self["Processors"] = list(set(self["Processors"]))
		processorOrderingkey = processorOrdering.processors_ordered(channel = self["Channel"])
		ordered_processors = processorOrderingkey.order_processors(self["Processors"])
		self["Processors"] = copy.deepcopy(ordered_processors)
    def build_config(
        self, nickname, *args, **kwargs
    ):  #Maybe change this the arguments to process/year and DATA/MC
        """
		"include" : [
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsVetoElectronID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMuonID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJEC.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJECUncertaintySplit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsBTaggedJetID.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsSvfit.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMinimalPlotlevelFilter_et.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Includes/settingsMVATestMethods.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauES.json",
			"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2CPStudies/Includes/settingsTauPolarisationMva.json"
		],
		"""

        datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
            os.path.expandvars(
                "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

        # define frequently used conditions
        isEmbedded = datasetsHelper.isEmbedded(nickname)
        isData = datasetsHelper.isData(nickname) and (not isEmbedded)

        ElectronID_config = sEID.Electron_ID(nickname)
        ElectronID_config.looseElectron_ID(
            nickname
        )  #append the config for loose electron ID because it is used
        ElectronID_config.vetoElectron_ID(nickname)
        self.update(ElectronID_config)

        MuonID_config = sMID.Muon_ID(nickname)
        MuonID_config.looseMuon_ID(
            nickname)  #append the config for loose Muon ID because it is used

        self.update(MuonID_config)

        TauID_config = sTID.Tau_ID(
            nickname
        )  #here loose is not appended since loose tau ID is not used
        self.update(TauID_config)

        JEC_config = sJEC.JEC(
            nickname
        )  #Is allready in baseconfig, for now leave it in; possibly remove it
        self.update(JEC_config)

        JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
        self.update(JECUncertaintySplit_config)

        JetID_config = sJID.Jet_ID(nickname)
        self.update(JetID_config)

        BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
        self.update(BTaggedJet_config)

        Svfit_config = sSvfit.Svfit(nickname)
        self.update(Svfit_config)

        MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
        MinimalPlotlevelFilter_config.et()
        self.update(MinimalPlotlevelFilter_config)

        MVATestMethods_config = sMVATM.MVATestMethods()
        self.update(MVATestMethods_config)

        TauES_config = sTES.TauES(nickname)
        self.update(TauES_config)

        TauPolarisationMva_config = sTPMVA.TauPolarisationMva()
        self.update(TauPolarisationMva_config)

        self["TauPolarisationTmvaWeights"] = [
            "/afs/cern.ch/user/m/mfackeld/public/weights_tmva/training.weights.xml",
            "/afs/cern.ch/user/m/mfackeld/public/weights_sklearn/training_et.weights.xml"
        ]
        self["Channel"] = "ET"
        self["MinNElectrons"] = 1
        self["MinNTaus"] = 1
        self[
            "HltPaths_comment"] = "The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer."

        self["NoHltFiltering"] = False  #else
        self["DiTauPairNoHLT"] = False

        self["ElectronLowerPtCuts"] = ["26.0"]  #default: !=2015
        self["DiTauPairLepton1LowerPtCuts"] = [
            "HLT_Ele25_eta2p1_WPTight_Gsf_v:26.0"
        ]  #default: !=2015 or !=2017

        if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
            self["HltPaths"] = ["HLT_Ele23_WPLoose_Gsf"]
            self["ElectronLowerPtCuts"] = ["24.0"]  #2015
            self["DiTauPairLepton1LowerPtCuts"] = [
                "HLT_Ele23_WPLoose_Gsf_v:24.0"
            ]  #2015

            self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
                "HLT_Ele23_WPLoose_Gsf_v"
            ]

        elif re.search(
                "Run2016|Spring16|Summer16", nickname
        ):  #spring16 self["NoHltFiltering"] = True for cp config False for RUN2 set to false here
            self["HltPaths"] = ["HLT_Ele25_eta2p1_WPTight_Gsf"]
            self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
                "HLT_Ele25_eta2p1_WPTight_Gsf_v"
            ]

        elif re.search("Embedding(2016|MC)", nickname):
            self["HltPaths"] = [""]
            self["NoHltFiltering"] = True  #else: self["NoHltFiltering"] = True
            self["DiTauPairNoHLT"] = True

            self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
                "HLT_Ele25_eta2p1_WPTight_Gsf_v"
            ]

        elif re.search("Run2017|Summer17|Fall17", nickname):
            self["HltPaths"] = [
                "HLT_Ele35_WPTight_Gsf", "HLT_Ele32_WPTight_Gsf"
            ]
            self["ElectronLowerPtCuts"] = ["36.0"]
            self["DiTauPairLepton1LowerPtCuts"] = [
                "HLT_Ele35_WPTight_Gsf_v:36.0", "HLT_Ele32_WPTight_Gsf_v:36.0"
            ]
            self["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
                "HLT_Ele35_WPTight_Gsf_v", "HLT_Ele32_WPTight_Gsf_v"
            ]

        self["TauID"] = "TauIDRecommendation13TeV"
        self["TauUseOldDMs"] = True

        self["ElectronUpperAbsEtaCuts"] = ["2.1"]
        self["TauLowerPtCuts"] = ["20.0"]
        self["TauUpperAbsEtaCuts"] = ["2.3"]
        self["TriggerObjectLowerPtCut"] = -1.0

        self["DiTauPairMinDeltaRCut"] = 0.5
        self["DiTauPairIsTauIsoMVA"] = True

        self["EventWeight"] = "eventWeight"
        self[
            "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_11_embedded.root" if isEmbedded else "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
        self["RooWorkspaceWeightNames"] = [
            "0:triggerWeight", "0:idIsoWeight"
        ] if not isEmbedded else [
            "0:triggerWeight_doublemu", "0:isoweight", "0:idweight",
            "0:triggerWeight_singleE"
        ]
        self["RooWorkspaceObjectNames"] = [
            "0:e_trgEle25eta2p1WPTight_desy_ratio", "0:e_idiso0p1_desy_ratio"
        ] if not isEmbedded else [
            "0:m_sel_trg_ratio", "0:e_iso_ratio", "0:e_id_ratio",
            "0:e_trg_ratio"
        ]
        self["RooWorkspaceObjectArguments"] = [
            "0:e_pt,e_eta", "0:e_pt,e_eta"
        ] if not isEmbedded else [
            "0:gt1_pt,gt1_eta,gt2_pt,gt2_eta", "0:e_pt,e_eta", "0:e_pt,e_eta",
            "0:e_pt,e_eta"
        ]

        if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
            self["TriggerEfficiencyData"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Electron_Ele23_fall15.root"
            ]
            self["TriggerEfficiencyMc"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele23_fall15.root"
            ]

            self["IdentificationEfficiencyData"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2015_Electron_IdIso0p1_fall15.root"
            ]
            self["IdentificationEfficiencyMc"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso0p1_fall15.root"
            ]

        elif re.search("Run2017|Summer17|Fall17", nickname):
            self["TriggerEfficiencyData"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2017_Electron_Ele32orEle35.root"
            ]
            self["TriggerEfficiencyMc"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MCFall2017_Electron_Ele32orEle35.root"
            ]

            self["IdentificationEfficiencyData"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2017_Electron_IdIso_IsoLt0.10_eff_RerecoFall17.root"
            ]
            self["IdentificationEfficiencyMc"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MCFall2017_Electron_IdIso_IsoLt0.10_eff_RerecoFall17.root"
            ]

        else:
            self["TriggerEfficiencyData"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele25WPTight_eff.root"
            ]
            self["TriggerEfficiencyMc"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele25WPTight_eff.root"
            ]

            self["IdentificationEfficiencyData"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p1_eff.root"
            ]
            self["IdentificationEfficiencyMc"] = [
                "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p1_eff.root"
            ]

        self["TriggerEfficiencyMode"] = "multiply_weights"
        self["IdentificationEfficiencyMode"] = "multiply_weights"
        if re.search("Run2017|Summer17|Fall17", nickname):
            self["EleTauFakeRateWeightFile"] = [""]

        else:
            self["EleTauFakeRateWeightFile"] = [
                "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
            ]
        self["TauTauRestFrameReco"] = "collinear_approximation"

        if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
            self["ElectronTriggerFilterNames"] = [
                "HLT_Ele23_WPLoose_Gsf_v:hltEle23WPLooseGsfTrackIsoFilter"
            ]

        elif re.search("Run2016|Spring16|Summer16|Embedding(2016|MC)",
                       nickname):
            self["ElectronTriggerFilterNames"] = [
                "HLT_Ele25_eta2p1_WPTight_Gsf_v:hltEle25erWPTightGsfTrackIsoFilter"
            ]

        elif re.search("Run2017|Summer17|Fall17", nickname):
            self["ElectronTriggerFilterNames"] = [
                "HLT_Ele35_WPTight_Gsf_v:hltEle35noerWPTightGsfTrackIsoFilter",
                "HLT_Ele32_WPTight_Gsf_v:hltEle32WPTightGsfTrackIsoFilter"
            ]

        if re.search("Run2016|Spring16|Summer16|Embedding2016", nickname):
            #settings for jetstotaufakesproducer
            self[
                "FakeFaktorFile"] = "root://grid-vo-cms.physik.rwth-aachen.de:1094//store/user/jdegens/higgs-kit/ff/2016/et/fakeFactors_20180831_tight.root"
            self["FakeFactorMethod"] = "cp2016"
            self["FakeFactorRooWorkspaceFunction"] = [
                "w_fracs:w_et_fracs", "qcd_fracs:qcd_et_fracs",
                "ttbar_fracs:ttbar_et_fracs"
            ]
            self[
                "FakeFactorFractionsRooWorkspaceFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/rooworkspacefractions/ff_fracs_new_2016.root"

        self["InvalidateNonMatchingElectrons"] = True
        self["InvalidateNonMatchingMuons"] = False
        self["InvalidateNonMatchingTaus"] = True
        self["InvalidateNonMatchingJets"] = False
        self["UseUWGenMatching"] = "true"
        self["DirectIso"] = True

        self["OSChargeLeptons"] = True
        self["SvfitKappaParameter"] = 4.0

        self["AddGenMatchedParticles"] = True
        self["AddGenMatchedTaus"] = True
        self["AddGenMatchedTauJets"] = True
        self["BranchGenMatchedElectrons"] = True
        self["BranchGenMatchedTaus"] = True
        self["Consumers"] = [
            "KappaLambdaNtupleConsumer", "cutflow_histogram",
            "SvfitCacheConsumer", "#CutFlowTreeConsumer",
            "#KappaElectronsConsumer", "#KappaTausConsumer",
            "#KappaTaggedJetsConsumer", "#RunTimeConsumer",
            "#PrintEventsConsumer", "#PrintGenParticleDecayTreeConsumer"
        ]

        quantities_dict = quantities.quantities()
        quantities_dict.build_quantities(nickname, channel=self["Channel"])

        #put rest of quantities in CPQuantities.py?

        quantities_dict["Quantities"] += [
            "nVetoElectrons", "nLooseElectrons", "nLooseMuons",
            "nDiTauPairCandidates", "nAllDiTauPairCandidates"
        ]

        if re.search(
                "(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16|Summer17|Fall17))",
                nickname):  #the same as tt

            # quantities_dict["Quantities"] += quantities_dict.lheWeightsDYQuantities()
            quantities_dict["Quantities"] += quantities_dict.genQuantities()

            quantities_dict["Quantities"] += [
                "tauSpinnerValidOutputs",
                "tauSpinnerPolarisation",
            ]

        elif re.search(
                "(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16|Summer17|Fall17))",
                nickname):

            quantities_dict["Quantities"] += [
                "#tauPolarisationTMVA",
                "#tauPolarisationSKLEARN",
            ]

        elif re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):

            quantities_dict["Quantities"] += [
                "tauSpinnerValidOutputs",
                "tauSpinnerPolarisation",
            ]

        elif re.search("Embedding2016", nickname):

            quantities_dict["Quantities"] += quantities_dict.genQuantities()

            quantities_dict["Quantities"] += [
                # "tauSpinnerValidOutputs",
                # "tauSpinnerPolarisation",
                "triggerWeight_doublemu_1",
                "isoweight_1",
                "idweight_1",
                "triggerWeight_singleE_1",
            ]

        elif re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
            quantities_dict["Quantities"] += ["jetCorrectionWeight"]

        self.update(copy.deepcopy(quantities_dict))

        self["Processors"] = [
            "producer:HltProducer",
            "filter:HltFilter",
            "producer:MetSelector",
            ################## special for each channel in et mt tt em.
            "producer:ValidElectronsProducer",
            "filter:ValidElectronsFilter",
            "producer:ElectronTriggerMatchingProducer",
            "filter:MinElectronsCountFilter",
            "producer:ValidMuonsProducer",
            "producer:ValidTausProducer",
            "filter:ValidTausFilter",
            "producer:TauTriggerMatchingProducer",
            "filter:MinTausCountFilter",
            "producer:ValidETPairCandidatesProducer",
            "filter:ValidDiTauPairCandidatesFilter",
            "producer:HttValidVetoElectronsProducer",
            "producer:HttValidLooseElectronsProducer",
            "producer:HttValidLooseMuonsProducer",
            "producer:DiVetoElectronVetoProducer",
            ##################
            "producer:Run2DecayChannelProducer",
            "producer:TaggedJetCorrectionsProducer",
            "producer:ValidTaggedJetsProducer",
            "producer:ValidBTaggedJetsProducer",
            "producer:TauTauRestFrameSelector",
            "producer:DiLeptonQuantitiesProducer",
            "producer:DiJetQuantitiesProducer",
        ]

        if re.search(
                "(Spring16|Summer16|Run2016|Run2017|Summer17|Fall17|Embedding2016)",
                nickname):
            self["Processors"] += ["producer:RefitVertexSelector"]
            self["Processors"] += ["producer:RecoTauCPProducer"]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitProducer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitM91Producer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSimpleFitProducer"
            ]
            self["Processors"] += ["producer:MetFilterProducer"]
            if re.search("(Run2017|Summer17|Fall17)", nickname) == None:
                self["Processors"] += [
                    "producer:TaggedJetUncertaintyShiftProducer"
                ]

            if re.search("(Run2016|Run2017|Embedding2016)", nickname):
                #self["Processors"] += ["producer:MVATestMethodsProducer"]
                self["Processors"] += ["producer:JetToTauFakesProducer"]

                self["Processors"] += ["producer:SimpleFitProducer"]
                #self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

                self["Processors"] += ["filter:MinimalPlotlevelFilter"]
                self["Processors"] += ["producer:SvfitProducer"]
                self["Processors"] += ["producer:SvfitM91Producer"]
                #				self["Processors"] += ["producer:SvfitM125Producer"]

                self["Processors"] += ["producer:MELAProducer"]
                #				self["Processors"] += ["producer:MELAM125Producer"]

                #self["Processors"] += ["producer:TauPolarisationTmvaReader"]
                if re.search("Embedding2016", nickname):
                    self["Processors"] += [
                        "producer:RooWorkspaceWeightProducer"
                    ]  #changes from file to file
                    self["Processors"] += ["producer:TauCorrectionsProducer"]

            else:
                self["Processors"] += ["producer:TauCorrectionsProducer"]
                self["Processors"] += ["producer:RooWorkspaceWeightProducer"
                                       ]  #changes from file to file
                self["Processors"] += ["producer:MetCorrector"]
                self["Processors"] += [
                    "producer:SimpleEleTauFakeRateWeightProducer",
                    "producer:SimpleMuTauFakeRateWeightProducer"
                ]

                if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
                    self["Processors"] += [
                        "producer:ZPtReweightProducer"
                        #"filter:MinimalPlotlevelFilter"
                    ]
                    self["Processors"] += ["producer:GenMatchedTauCPProducer"]
                    self["Processors"] += [
                        "producer:LFVJetCorrection2016Producer"
                    ]

                else:
                    self["Processors"] += ["filter:MinimalPlotlevelFilter"]
                    self["Processors"] += ["producer:SvfitProducer"]
                    self["Processors"] += ["producer:SvfitM91Producer"]
                    #					self["Processors"] += ["producer:SvfitM125Producer"]

                    self["Processors"] += ["producer:MELAProducer"]
                    #					self["Processors"] += ["producer:MELAM125Producer"]

                    if re.search(
                            "(DY.?JetsTo(LL|TauTau)).*(?=(Spring16|Summer16|Summer17|Fall17))",
                            nickname):
                        self["Processors"] += [
                            "producer:JetToTauFakesProducer"
                        ]
                        self["Processors"] += ["producer:ZPtReweightProducer"]

                        self["Processors"] += ["producer:SimpleFitProducer"]
                        self["Processors"] += [
                            "producer:GenMatchedTauCPProducer"
                        ]
                        self["Processors"] += [
                            "producer:GenMatchedPolarisationQuantitiesProducer"
                        ]

                        #self["Processors"] += ["producer:TauPolarisationTmvaReader"]

                    elif re.search(
                            "(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16|Summer17|Fall17))",
                            nickname):
                        self["Processors"] += [
                            "producer:TopPtReweightingProducer"
                        ]
                        #self["Processors"] += ["producer:MVATestMethodsProducer"]
                        self["Processors"] += [
                            "producer:GenMatchedTauCPProducer"
                        ]
                        #self["Processors"] += ["producer:TauPolarisationTmvaReader"]
                        #self["Processors"] += ["producer:MadGraphReweightingProducer"]
                    else:
                        self["Processors"] += [
                            "producer:TopPtReweightingProducer"
                        ]
                        #self["Processors"] += ["producer:MVATestMethodsProducer"]
                        self["Processors"] += ["producer:SimpleFitProducer"]
                        self["Processors"] += [
                            "producer:GenMatchedPolarisationQuantitiesProducer"
                        ]
                        self["Processors"] += [
                            "producer:JetToTauFakesProducer"
                        ]

                        #self["Processors"] += ["producer:TauPolarisationTmvaReader"]

        elif re.search("(Fall15|Run2015)", nickname):
            #self["Processors"] += ["producer:RefitVertexSelector"]
            self["Processors"] += ["producer:RecoTauCPProducer"]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitProducer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSvfitM91Producer"
            ]
            self["Processors"] += [
                "producer:PolarisationQuantitiesSimpleFitProducer"
            ]
            self["Processors"] += ["filter:MinimalPlotlevelFilter"]
            self["Processors"] += ["producer:MvaMetSelector"]

            if re.search("Run2015", nickname):
                #self["Processors"] += ["producer:SimpleFitProducer"]
                self["Processors"] += [
                    "producer:GenMatchedPolarisationQuantitiesProducer"
                ]

                #self["Processors"] += ["producer:SvfitProducer"]
                #self["Processors"] += ["producer:SvfitM91Producer"]
                #self["Processors"] += ["producer:SvfitM125Producer"]

                #self["Processors"] += ["producer:MELAProducer"]
                #self["Processors"] += ["producer:MELAM125Producer"]
            else:

                self["Processors"] += ["producer:MvaMetCorrector"]
                self["Processors"] += ["producer:MetCorrector"]
                self["Processors"] += ["producer:TauCorrectionsProducer"]
                self["Processors"] += ["producer:EleTauFakeRateWeightProducer"]
                if re.search("(DY.?JetsTo(LL|TauTau)).*(?=Fall15)", nickname):
                    self["Processors"] += ["producer:ZPtReweightProducer"]
                    #self["Processors"] += ["producer:SimpleFitProducer"]
                    self["Processors"] += ["producer:GenMatchedTauCPProducer"]
                    self["Processors"] += [
                        "producer:GenMatchedPolarisationQuantitiesProducer"
                    ]

                elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",
                               nickname):
                    self["Processors"] += ["producer:SvfitProducer"]
                    self["Processors"] += ["producer:SvfitM91Producer"]
                    #					self["Processors"] += ["producer:SvfitM125Producer"]

                    self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

                elif re.search(
                        "^((?!(DY.?JetsTo(LL|TauTau)|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15",
                        nickname):
                    self["Processors"] += ["producer:SvfitProducer"]
                    self["Processors"] += ["producer:SvfitM91Producer"]
                    #					self["Processors"] += ["producer:SvfitM125Producer"]

                    self["Processors"] += ["producer:MELAProducer"]
#					self["Processors"] += ["producer:MELAM125Producer"]

        self["Processors"] += ["producer:EventWeightProducer"]
        self["Processors"] = list(set(self["Processors"]))
        processorOrderingkey = processorOrdering.processors_ordered(
            channel=self["Channel"])
        ordered_processors = processorOrderingkey.order_processors(
            self["Processors"])
        self["Processors"] = copy.deepcopy(ordered_processors)
Exemple #22
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauES",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsMinimalPlotlevelFilter_tt"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "TT"
    config["MinNTaus"] = 2
    config["HltPaths"] = [
        "HLT_IsoMu22", "HLT_IsoTkMu22", "HLT_IsoMu22_eta2p1",
        "HLT_IsoTkMu22_eta2p1", "HLT_VLooseIsoPFTau120_Trk50_eta2p1",
        "HLT_Ele25_eta2p1_WPTight_Gsf",
        "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg",
        "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg",
        "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL",
        "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
    ]

    config["TauID"] = "TauIDRecommendation13TeV"
    config["TauUseOldDMs"] = True
    config["TauLowerPtCuts"] = ["40.0"]
    config["TauUpperAbsEtaCuts"] = ["2.1"]
    config["DiTauPairMinDeltaRCut"] = 0.5
    config["DiTauPairIsTauIsoMVA"] = True
    config["DiTauPairHLTLast"] = True
    config["HLTBranchNames"] = [
        "trg_singlemuon:HLT_IsoMu22_v", "trg_singlemuon:HLT_IsoTkMu22_v",
        "trg_singlemuon:HLT_IsoMu22_eta2p1_v",
        "trg_singlemuon:HLT_IsoTkMu22_eta2p1_v",
        "trg_singletau:HLT_VLooseIsoPFTau120_Trk50_eta2p1_v",
        "trg_singleelectron:HLT_Ele25_eta2p1_WPTight_Gsf_v",
        "trg_doubletau:HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v",
        "trg_doubletau:HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v",
        "trg_muonelectron:HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v",
        "trg_muonelectron:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v"
    ]
    config["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
        "HLT_IsoMu22_v", "HLT_IsoTkMu22_v", "HLT_IsoMu22_eta2p1_v",
        "HLT_IsoTkMu22_eta2p1_v", "HLT_VLooseIsoPFTau120_Trk50_eta2p1_v",
        "HLT_Ele25_eta2p1_WPTight_Gsf_v"
    ]
    config["EventWeight"] = "eventWeight"
    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
    config[
        "TauTauTriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
    config["TauTauTriggerWeightWorkspaceWeightNames"] = [
        "0:triggerWeight", "1:triggerWeight"
    ]
    config["TauTauTriggerWeightWorkspaceObjectNames"] = [
        "0:t_genuine_MediumIso_tt_ratio,t_fake_MediumIso_tt_ratio",
        "1:t_genuine_MediumIso_tt_ratio,t_fake_MediumIso_tt_ratio"
    ]
    config["TauTauTriggerWeightWorkspaceObjectArguments"] = [
        "0:t_pt,t_dm", "1:t_pt,t_dm"
    ]
    config["FakeFaktorFiles"] = [
        "inclusive:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/medium/tt/inclusive/fakeFactors_20170628_medium.root",
        "nobtag:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/medium/tt/nobtag/fakeFactors_20170628_medium.root",
        "btag:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/medium/tt/btag/fakeFactors_20170628_medium.root"
    ]

    config["TauTauRestFrameReco"] = "collinear_approximation"
    config["TauTriggerFilterNames"] = [
        "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg",
        "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"
    ]
    config["TriggerObjectLowerPtCut"] = 28.0
    config["BTagWPs"] = ["medium"]
    config["InvalidateNonMatchingElectrons"] = False
    config["InvalidateNonMatchingMuons"] = False
    config["InvalidateNonMatchingTaus"] = True
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.syncQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.MVAInputQuantities").build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.lheWeights"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.zptQuantities"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.fakeFactorWeightQuantities_tt"
        ).build_list())
    config["Quantities"].extend(["had_gen_match_pT_1", "had_gen_match_pT_2"])

    config["OSChargeLeptons"] = True
    config["TopPtReweightingStrategy"] = "Run1"

    config["Processors"] = [
        "producer:HttValidLooseElectronsProducer",
        "producer:HttValidLooseMuonsProducer", "producer:HltProducer",
        "producer:MetSelector"
    ]
    if not isData:
        config["Processors"].append("producer:TauCorrectionsProducer")
    config["Processors"].extend((
        "producer:ValidTausProducer",
        "filter:ValidTausFilter",
        "producer:TauTriggerMatchingProducer",
        "filter:MinTausCountFilter",
        "producer:ValidElectronsProducer",
        "producer:ValidMuonsProducer",
        "producer:ValidTTPairCandidatesProducer",
        "filter:ValidDiTauPairCandidatesFilter",
        "producer:Run2DecayChannelProducer",  #"producer:MvaMetSelector",
        "producer:ValidTaggedJetsProducer",
        "producer:ValidBTaggedJetsProducer",
        "producer:TaggedJetCorrectionsProducer"))
    if not isData:
        config["Processors"].extend((
            "producer:MetCorrector",  #"producer:MvaMetCorrector"
            "producer:SimpleEleTauFakeRateWeightProducer",
            "producer:SimpleMuTauFakeRateWeightProducer",
            "producer:TauTauTriggerWeightProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    if isDY or isEmbedded:
        config["Processors"].append("producer:ZPtReweightProducer")
    config["Processors"].extend(
        ("filter:MinimalPlotlevelFilter", "producer:TauTauRestFrameSelector",
         "producer:DiLeptonQuantitiesProducer",
         "producer:DiJetQuantitiesProducer", "producer:JetToTauFakesProducer",
         "producer:EventWeightProducer"))

    config["AddGenMatchedTaus"] = True
    config["AddGenMatchedTauJets"] = True
    config["BranchGenMatchedTaus"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer", "cutflow_histogram"]
    #"CutFlowTreeConsumer",
    #"KappaElectronsConsumer",
    #"KappaTausConsumer",
    #"KappaTaggedJetsConsumer",
    #"RunTimeConsumer",
    #"PrintEventsConsumer"

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'tt', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.syst_shifts"
        ).build_config(nickname))
# Object-related settings should be done in designated python configs
# if possible, run2 configs import the run1 configs and add some extra information
## ------------------------------------------------------------------------

# Kappa test: CMSSW 7.6.3, 8.0.20
# Kappa test: scram arch slc6_amd64_gcc493, slc6_amd64_gcc530
# Kappa test: checkout script scripts/checkoutCmssw76xPackagesForSkimming.py, scripts/checkoutCmssw80xPackagesForSkimming.py
# Kappa test: output kappaTuple.root
import sys
if not hasattr(sys, 'argv'):
	sys.argv = ["cmsRun", "runFrameworkMC.py"]

import os
import FWCore.ParameterSet.Config as cms
from  Kappa.Skimming.datasetsHelperTwopz import datasetsHelperTwopz
datasetsHelper = datasetsHelperTwopz(os.path.join(os.environ.get("CMSSW_BASE"),"src/Kappa/Skimming/data/datasets.json"))
import Kappa.Skimming.tools as tools

from FWCore.ParameterSet.VarParsing import VarParsing
options = VarParsing('python')
options.register('globalTag', '76X_mcRun2_asymptotic_RunIIFall15DR76_v1', VarParsing.multiplicity.singleton, VarParsing.varType.string, 'GlobalTag')
options.register('kappaTag', 'KAPPA_2_0_0', VarParsing.multiplicity.singleton, VarParsing.varType.string, 'KappaTag')
options.register('nickname', 'SUSYGluGluToHToTauTauM160_RunIIFall15MiniAODv2_PU25nsData2015v1_13TeV_MINIAOD_pythia8', VarParsing.multiplicity.singleton, VarParsing.varType.string, 'Dataset Nickname')
options.register('testfile', '', VarParsing.multiplicity.singleton, VarParsing.varType.string, 'Path for a testfile')
options.register('maxevents', -1, VarParsing.multiplicity.singleton, VarParsing.varType.int, 'maxevents. -1 for all events. Default: -1')
options.register('outputfilename', '', VarParsing.multiplicity.singleton, VarParsing.varType.string, 'Filename for the Outputfile')
options.register('testsuite', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool, 'Run the Kappa test suite. Default: True')
options.register('preselect', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool, 'apply preselection at CMSSW level on leptons. Never preselect on SM Higgs samples')
options.register('dumpPython', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool, 'write cmsRun config to dumpPython.py')
options.parseArguments()
	def build_config(self, nickname, *args, **kwargs):                #Maybe change this the arguments to process/year and DATA/MC

		#Change this json config files as well?
		"""
		if hasattr(self, "include") == False:
			self["include"] = []
		self["include"] += ["$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseElectronID.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsLooseMuonID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsElectronID.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMuonID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJEC.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJECUncertaintySplit.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsJetID.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsBTaggedJetID.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsSvfit.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsMinimalPlotlevelFilter_tt.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Includes/settingsMVATestMethods.json",  #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2Analysis/Includes/settingsTauES.json", #Done
				"$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/ArtusConfigs/Run2CPStudies/Includes/settingsTauPolarisationMva.json"] #Done
		"""

		datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

		# define frequently used conditions
		isEmbedded = datasetsHelper.isEmbedded(nickname)
		isData = datasetsHelper.isData(nickname) and (not isEmbedded)

		ElectronID_config = sEID.Electron_ID(nickname)
		ElectronID_config.looseElectron_ID(nickname) 		#append the config for loose electron ID because it is used
		self.update(ElectronID_config)

		MuonID_config = sMID.Muon_ID(nickname)
		MuonID_config.looseMuon_ID(nickname) 		#append the config for loose Muon ID because it is used
		self.update(MuonID_config)

		TauID_config = sTID.Tau_ID(nickname)			#here loose is not appended since loose tau ID is not used
		self.update(TauID_config)

		JEC_config = sJEC.JEC(nickname)  #Is allready in baseconfig, for now leave it in; possibly remove it
		self.update(JEC_config)

		JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
		self.update(JECUncertaintySplit_config)

		JetID_config = sJID.Jet_ID(nickname)
		self.update(JetID_config)

		BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
		self.update(BTaggedJet_config)

		Svfit_config = sSvfit.Svfit(nickname)
		self.update(Svfit_config)

		MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
		MinimalPlotlevelFilter_config.tt()
		self.update(MinimalPlotlevelFilter_config)
		
		MVATestMethods_config = sMVATM.MVATestMethods()
		self.update(MVATestMethods_config)

		TauES_config = sTES.TauES(nickname)
		self.update(TauES_config)
		
		TauPolarisationMva_config = sTPMVA.TauPolarisationMva()
		self.update(TauPolarisationMva_config)
		
		self["TauPolarisationTmvaWeights"] = ["/afs/cern.ch/user/m/mfackeld/public/weights_tmva/training.weights.xml",
						"/afs/cern.ch/user/m/mfackeld/public/weights_sklearn/training_tt.weights.xml"]

		self["Channel"] = "TT"
		self["MinNTaus"] = 2
		self["TauID"] = "TauIDRecommendation13TeV"
		self["TauUseOldDMs"] = True
		self["TauLowerPtCuts"] = ["40.0"]  #in json with default
		self["TauUpperAbsEtaCuts"] = ["2.1"] #in json with default
		self["DiTauPairMinDeltaRCut"] = 0.5
		self["DiTauPairIsTauIsoMVA"] = True
		self["EventWeight"] = "eventWeight"
		self["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
		if isEmbedded:
			self["EmbeddingWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_11_embedded.root"

			self["EmbeddingWeightWorkspaceWeightNames"] = [
				"0:triggerWeight_doublemu",
				"0:triggerWeight_tau",
				"1:triggerWeight_tau"
			]
			self["EmbeddingWeightWorkspaceObjectNames"] = [
				"0:m_sel_trg_ratio",
				"0:t_TightIso_tt_emb_ratio",
				"1:t_TightIso_tt_emb_ratio"
			]
			self["EmbeddingWeightWorkspaceObjectArguments"] = [
				"0:gt1_pt,gt1_eta,gt2_pt,gt2_eta",
				"0:t_pt,t_dm",
				"1:t_pt,t_dm"
			]
		else:
			self["TauTauTriggerWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"

			self["TauTauTriggerWeightWorkspaceWeightNames"] = [
				"0:triggerWeight",
				"1:triggerWeight"
			]
			self["TauTauTriggerWeightWorkspaceObjectNames"] = [
				"0:t_genuine_TightIso_tt_ratio,t_fake_TightIso_tt_ratio",
				"1:t_genuine_TightIso_tt_ratio,t_fake_TightIso_tt_ratio"
			]
			self["TauTauTriggerWeightWorkspaceObjectArguments"] = [
				"0:t_pt,t_dm",
				"1:t_pt,t_dm"
			]
			self["EleTauFakeRateWeightFile"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"
			]

		if re.search("Run2016|Spring16|Summer16|Embedding2016", nickname):
			#settings for jetstotaufakesproducer
			self["FakeFaktorFile"] = "root://grid-vo-cms.physik.rwth-aachen.de:1094//store/user/jdegens/higgs-kit/ff/2016/tt/fakeFactors_tt_inclusive.root"
			self["FakeFactorMethod"] = "cp2016"
			self["FakeFactorRooWorkspaceFunction"] = [
				"w_fracs_1:w_tt_fracs_1",
				"qcd_fracs_1:qcd_tt_fracs_1",
				"ttbar_fracs_1:ttbar_tt_fracs_1",
				"dy_fracs_1:dy_tt_fracs_1",
				"w_fracs_2:w_tt_fracs_2",
				"qcd_fracs_2:qcd_tt_fracs_2",
				"ttbar_fracs_2:ttbar_tt_fracs_2",
				"dy_fracs_2:dy_tt_fracs_2"
			]
			self["FakeFactorFractionsRooWorkspaceFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/rooworkspacefractions/ff_fracs_new_2016.root"

		
		self["TauTauRestFrameReco"] = "collinear_approximation"
		self["TriggerObjectLowerPtCut"] = 28.0
		self["InvalidateNonMatchingElectrons"] = False
		self["InvalidateNonMatchingMuons"] = False
		self["InvalidateNonMatchingTaus"] = True
		self["InvalidateNonMatchingJets"] = False
		self["UseUWGenMatching"] = "true"                   #TODO change this to boolean? or change the rest to string?
		self["DirectIso"] = True
		self["TopPtReweightingStrategy"] = "Run2" #FIXME this looks more right

		self["OSChargeLeptons"] = True
		self["SvfitKappaParameter"] = 5.0

		self["AddGenMatchedTaus"] = True
		self["AddGenMatchedTauJets"] = True
		self["BranchGenMatchedTaus"] = True

		self["Consumers"] = ["KappaLambdaNtupleConsumer",
			"cutflow_histogram",
			"SvfitCacheConsumer"]#,
			#"CutFlowTreeConsumer",
			#"KappaTausConsumer",
			#"KappaTaggedJetsConsumer",
			#"RunTimeConsumer",
			#"PrintEventsConsumer",
			#"PrintGenParticleDecayTreeConsumer"]

		if re.search("Embedding", nickname):
			self["NoHltFiltering"]= True
			self["DiTauPairNoHLT"]= True
		else:
			self["NoHltFiltering"]= False
			self["DiTauPairNoHLT"]= True

		 #set it here and if it is something else then change it in the ifs below
		self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg", "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg"]
		self["TauTriggerFilterNames"] = [
			"HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg",   #here are : in string
			"HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"
		]

		if "Run2016" in nickname and not "Run2016H" in nickname:
			self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg"]
			self["TauTriggerFilterNames"]=["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg"]


		elif "Run2016H" in nickname:
			self["HltPaths"] = ["HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg"]
			self["TauTriggerFilterNames"] = ["HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumCombinedIsolationDz02Reg"]

		elif "Fall15MiniAODv2" in nickname or "Run2015D" in nickname or "Embedding2015" in nickname:
			self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg"]
			self["TauTriggerFilterNames"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35TrackPt1MediumIsolationDz02Reg"]

		elif "Embedding2016" in nickname or "EmbeddingMC" in nickname:	 #TODO Ask thomas what it should be line 40 in json
			self["HltPaths"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v"]
			self["TauTriggerFilterNames"] = ["HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v:hltDoublePFTau35Reg"]

		#Quantities, this looks for tt em mt et very similar, check if it is the same and if so put it in baseconfig for all channels
		quantities_dict = quantities.quantities()
		quantities_dict.build_quantities(nickname, channel = self["Channel"])

		#put rest of quantities in CPQuantities.py?

		quantities_dict["Quantities"] += [
						"nLooseElectrons",
						"nLooseMuons",
						"nDiTauPairCandidates",
						 "nAllDiTauPairCandidates"
					]
		if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):
			quantities_dict["Quantities"] += quantities_dict.genMatchedCPQuantities()
		elif re.search("Embedding2016", nickname):
			quantities_dict["Quantities"] += [
				# "tauSpinnerValidOutputs",
				# "tauSpinnerPolarisation",
				"triggerWeight_doublemu_1",
				"triggerWeight_tau_1",
				"triggerWeight_tau_2"
			]

		self.update(copy.deepcopy(quantities_dict))

		#Producers and filters, TODO filter everything which is the same and use this as the startint list, then just add the other variables per sample

		self["Processors"] = [
				"producer:HltProducer",
				"filter:HltFilter",
				"producer:MetSelector",
				################## special for each channel in et mt tt em.
				"producer:ValidTausProducer",
				"filter:ValidTausFilter", 
				"producer:TauTriggerMatchingProducer", 
				"filter:MinTausCountFilter", 
				"producer:ValidElectronsProducer",
				"producer:ValidMuonsProducer",
				"producer:ValidTTPairCandidatesProducer", 
				"filter:ValidDiTauPairCandidatesFilter", 
				"producer:HttValidLooseElectronsProducer", 
				"producer:HttValidLooseMuonsProducer", 
				##################
				"producer:Run2DecayChannelProducer",          
				"producer:TaggedJetCorrectionsProducer",
				"producer:ValidTaggedJetsProducer",
				"producer:ValidBTaggedJetsProducer",	
				"producer:TauTauRestFrameSelector",
				"producer:DiLeptonQuantitiesProducer",
				"producer:DiJetQuantitiesProducer",
				
				]

		if re.search("(Spring16|Summer16|Run2016|Embedding2016)", nickname):
			self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["producer:TaggedJetUncertaintyShiftProducer"]
			self["Processors"]+= ["producer:MetFilterProducer"]

			if re.search("(Run2016|Embedding2016)", nickname):
				#self["Processors"] += ["producer:MVATestMethodsProducer"]

				self["Processors"] += ["producer:SimpleFitProducer"]
				#self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				self["Processors"] += ["filter:MinimalPlotlevelFilter"]
				self["Processors"] += ["producer:SvfitProducer"]
				self["Processors"] += ["producer:SvfitM91Producer"]
				self["Processors"] += ["producer:SvfitM125Producer"]

				self["Processors"] += ["producer:MELAProducer"]
				self["Processors"] += ["producer:MELAM125Producer"]

				self["Processors"] += ["producer:JetToTauFakesProducer"] #TODO check if only needed in data


				#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

				if re.search("Embedding2016", nickname):
					self["Processors"] += ["producer:RooWorkspaceWeightProducer"]
					self["Processors"] += ["producer:TauCorrectionsProducer"]
					self["Processors"] += ["producer:EmbeddingWeightProducer"]

			else:
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:TauTauTriggerWeightProducer"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += [
						"producer:SimpleEleTauFakeRateWeightProducer",
						"producer:SimpleMuTauFakeRateWeightProducer"
						]

				if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
					self["Processors"] += [
						"producer:ZPtReweightProducer"
						#"filter:MinimalPlotlevelFilter"
					]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]

				else:              
					self["Processors"] += ["filter:MinimalPlotlevelFilter"]
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]
			


					if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += ["producer:JetToTauFakesProducer"] #TODO also needed for mc to -
						self["Processors"] += ["producer:ZPtReweightProducer"]			

						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

					elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += [
							"producer:TopPtReweightingProducer"
						] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
						#self["Processors"] += ["producer:MadGraphReweightingProducer"]
					else:
						self["Processors"] += ["producer:JetToTauFakesProducer"] #TODO Also needed for MC to -
						self["Processors"] += [	"producer:TopPtReweightingProducer"] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:SimpleFitProducer"]				
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
				
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

		elif re.search("(Fall15|Run2015)", nickname):
			#self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["filter:MinimalPlotlevelFilter"]
			self["Processors"] += ["producer:MvaMetSelector"]


			if re.search("Run2015", nickname):
				#self["Processors"] += ["producer:SimpleFitProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				#self["Processors"] += ["producer:SvfitProducer"]
				#self["Processors"] += ["producer:SvfitM91Producer"]
				#self["Processors"] += ["producer:SvfitM125Producer"]

				#self["Processors"] += ["producer:MELAProducer"]
				#self["Processors"] += ["producer:MELAM125Producer"]

			else:
				self["Processors"] += ["producer:MvaMetCorrector"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += [
					"producer:EleTauFakeRateWeightProducer"
				]

				if re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):

					self["Processors"] += ["producer:ZPtReweightProducer"]			
					#self["Processors"] += ["producer:SimpleFitProducer"]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]



				elif re.search("^((?!(DY.?JetsToLL|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

		self["Processors"] += ["producer:EventWeightProducer"]
		self["Processors"] = list(set(self["Processors"]))
		processorOrderingkey = processorOrdering.processors_ordered(channel = self["Channel"])
		ordered_processors = processorOrderingkey.order_processors(self["Processors"])
		self["Processors"] = copy.deepcopy(ordered_processors)
Exemple #25
0
def build_config(nickname):
  config = jsonTools.JsonDict()
  datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))
  
  
  # define frequently used conditions
  isEmbedded = datasetsHelper.isEmbedded(nickname)
  isData = datasetsHelper.isData(nickname) and (not isEmbedded)
  isTTbar = re.search("TT(To|_|Jets)", nickname)
  isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
  isWjets = re.search("W.?JetsToLNu", nickname)
  isHtt = re.search("HToTauTau", nickname)
  
  
  ## fill config:
  # includes
  includes = [
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseElectronID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseMuonID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsElectronID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsVetoMuonID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsMuonID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJEC",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJetID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsBTaggedJetID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauES",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_mm"
  ]
  for include_file in includes:
    analysis_config_module = importlib.import_module(include_file)
    config += analysis_config_module.build_config(nickname)
  
  # explicit configuration
  config["Channel"] = "MM"
  config["MinNMuons"] = 2
  # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
  if re.search("(Run2016|Embedding2016|Summer16)", nickname): config["HltPaths"] = [
          "HLT_IsoMu22",
          "HLT_IsoTkMu22",
          "HLT_IsoMu22_eta2p1",
          "HLT_IsoTkMu22_eta2p1",
          "HLT_VLooseIsoPFTau120_Trk50_eta2p1",
          "HLT_Ele25_eta2p1_WPTight_Gsf",
          "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg",
          "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg",
          "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL",
          "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
    ]
  
  config["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
  config["RooWorkspaceWeightNames"] = [
      "0:triggerWeight",
      "0:isoweight",
      "0:idweight",
      "0:trackWeight",
      "1:isoweight",
      "1:idweight",
      "1:trackWeight"
  ]
  config["RooWorkspaceObjectNames"] = [
      "0:m_trgOR4_binned_ratio",
      "0:m_iso_binned_ratio",
      "0:m_id_ratio",
      "0:m_trk_ratio",
      "1:m_iso_binned_ratio",
      "1:m_id_ratio",
      "1:m_trk_ratio"
  ]
  config["RooWorkspaceObjectArguments"] = [
      "0:m_pt,m_eta,m_iso",
      "0:m_pt,m_eta,m_iso",
      "0:m_pt,m_eta",
      "0:m_eta",
      "1:m_pt,m_eta,m_iso",
      "1:m_pt,m_eta",
      "1:m_eta"
  ]
  config["TauID"] = "TauIDRecommendation13TeV"
  config["TauUseOldDMs"] = True
  config["MuonLowerPtCuts"] = ["10.0"]
  config["MuonUpperAbsEtaCuts"] = ["2.1"]
  config["DiTauPairMinDeltaRCut"] = 0.3
  config["DiTauPairIsTauIsoMVA"] = True
  config["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
      "HLT_IsoMu22_v",
      "HLT_IsoTkMu22_v",
      "HLT_IsoMu22_eta2p1_v",
      "HLT_IsoTkMu22_eta2p1_v",
      "HLT_VLooseIsoPFTau120_Trk50_eta2p1_v",
      "HLT_Ele25_eta2p1_WPTight_Gsf_v"]
  config["DiTauPairHLTLast"] = True
  config["HLTBranchNames"] = [
      "trg_singlemuon:HLT_IsoMu22_v",
      "trg_singlemuon:HLT_IsoTkMu22_v",
      "trg_singlemuon:HLT_IsoMu22_eta2p1_v",
      "trg_singlemuon:HLT_IsoTkMu22_eta2p1_v",
      "trg_singletau:HLT_VLooseIsoPFTau120_Trk50_eta2p1_v",
      "trg_singleelectron:HLT_Ele25_eta2p1_WPTight_Gsf_v",
      "trg_doubletau:HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v",
      "trg_doubletau:HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v",
      "trg_muonelectron:HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v",
      "trg_muonelectron:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v"]
  config["DiTauPairLepton1LowerPtCuts"] = [
      "HLT_IsoMu22_v:23.0",
      "HLT_IsoTkMu22_v:23.0",
      "HLT_IsoMu22_eta2p1_v:23.0",
      "HLT_IsoTkMu22_eta2p1_v:23.0"
    ]
  config["EventWeight"] = "eventWeight"
  config["TauTauRestFrameReco"] = "collinear_approximation"
  if re.search("(Run2016|Embedding2016|Summer16)", nickname): config["MuonTriggerFilterNames"] = [
          "HLT_IsoMu22_v:hltL3crIsoL1sMu20L1f0L2f10QL3f22QL3trkIsoFiltered0p09",
          "HLT_IsoTkMu22_v:hltL3fL1sMu20L1f0Tkf22QL3trkIsoFiltered0p09",
          "HLT_IsoMu22_eta2p1_v:hltL3crIsoL1sSingleMu20erL1f0L2f10QL3f22QL3trkIsoFiltered0p09",
          "HLT_IsoTkMu22_eta2p1_v:hltL3fL1sMu20erL1f0Tkf22QL3trkIsoFiltered0p09",
          "HLT_VLooseIsoPFTau120_Trk50_eta2p1_v:hltPFTau120TrackPt50LooseAbsOrRelVLooseIso"]
  config["BTagWPs"] = ["medium"]
  config["InvalidateNonMatchingElectrons"] = False
  config["InvalidateNonMatchingMuons"] = True
  config["InvalidateNonMatchingTaus"] = False
  config["InvalidateNonMatchingJets"] = False
  config["DirectIso"] = True
  
  config["Quantities"] = importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.syncQuantities").build_list()
  config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities").build_list())
  #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.MVAInputQuantities").build_list())
  config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.zptQuantities").build_list())
  config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.lheWeights").build_list())
  config["Quantities"].extend([
      "had_gen_match_pT_1",
      "had_gen_match_pT_2"
  ])
  
  config["OSChargeLeptons"] = True
  config["TopPtReweightingStrategy"] = "Run1"
  if re.search("(Fall15MiniAODv2|Run2015)", nickname):
    config["MuonEnergyCorrection"] = "rochcorr2015"
    config["MuonRochesterCorrectionsFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/rochcorr/RoccoR_13tev_2015.txt"
  else:
    config["MuonEnergyCorrection"] = "rochcorr2016"
    config["MuonRochesterCorrectionsFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/rochcorr2016"
  
  #config["Processors"] =                                     ["producer:MuonCorrectionsProducer"]
  config["Processors"] = [                                    "producer:HltProducer",
                                                              "producer:MetSelector",
                                                              "producer:HttValidLooseElectronsProducer",
                                                              "producer:HttValidLooseMuonsProducer",
                                                              "producer:ValidMuonsProducer",
                                                              "filter:ValidMuonsFilter",
                                                              "producer:MuonTriggerMatchingProducer",
                                                              "filter:MinMuonsCountFilter",
                                                              "producer:HttValidVetoMuonsProducer",
                                                              "producer:ValidElectronsProducer"]
  if isDY or isWjets or isHtt:   config["Processors"].append( "producer:TauCorrectionsProducer")
  config["Processors"].extend((                               "producer:ValidTausProducer",
                                                              "producer:TauTriggerMatchingProducer",
                                                              "producer:ValidMMPairCandidatesProducer",
                                                              "filter:ValidDiTauPairCandidatesFilter",
                                                              "producer:Run2DecayChannelProducer",#"producer:MvaMetSelector",
                                                              "producer:DiVetoMuonVetoProducer",
                                                              "producer:TaggedJetCorrectionsProducer",
                                                              "producer:ValidTaggedJetsProducer",
                                                              "producer:ValidBTaggedJetsProducer"))
  if isDY or isWjets or isHtt:   config["Processors"].append( "producer:MetCorrector") #"producer:MvaMetCorrector"
  config["Processors"].extend((                               "producer:TauTauRestFrameSelector",
                                                              "producer:DiLeptonQuantitiesProducer",
                                                              "producer:DiJetQuantitiesProducer"))
  if isTTbar:                    config["Processors"].append( "producer:TopPtReweightingProducer")
  if isDY:                       config["Processors"].append( "producer:ZPtReweightProducer")
  config["Processors"].append(                                "filter:MinimalPlotlevelFilter") #"producer:MVATestMethodsProducer",
                                                              #"producer:MVAInputQuantitiesProducer"))
  if not isData:                 config["Processors"].append( #"producer:TriggerWeightProducer", "producer:IdentificationWeightProducer"
                                                              "producer:RooWorkspaceWeightProducer")
  config["Processors"].append(                                "producer:EventWeightProducer")
  
    
  
  config["AddGenMatchedParticles"] = True
  config["AddGenMatchedTaus"] = True
  config["AddGenMatchedTauJets"] = True
  config["BranchGenMatchedMuons"] = True
  config["BranchGenMatchedTaus"] = True
  config["Consumers"] = ["KappaLambdaNtupleConsumer",
                         "cutflow_histogram"]
                         #"CutFlowTreeConsumer",
                         #"KappaElectronsConsumer",
                         #"KappaTausConsumer",
                         #"KappaTaggedJetsConsumer",
                         #"RunTimeConsumer",
                         #"PrintEventsConsumer"
  
  
  # pipelines - systematic shifts
  return ACU.apply_uncertainty_shift_configs('mm', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.syst_shifts_nom").build_config(nickname))
Exemple #26
0
def build_config(nickname):
  config = jsonTools.JsonDict()
  datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))
  
  
  # define frequently used conditions
  isEmbedded = datasetsHelper.isEmbedded(nickname)
  isData = datasetsHelper.isData(nickname) and (not isEmbedded)
  isTTbar = re.search("TT(To|_|Jets)", nickname)
  isDY = re.search("(DY.?JetsToLL|EWKZ2Jets)", nickname)
  isWjets = re.search("W.?JetsToLNu", nickname)
  isGluonFusion = re.search("GluGluHToTauTauM125", nickname)
  
  
  ## fill config:
  # includes
  includes = [
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseElectronID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseMuonID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsElectronID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsVetoElectronID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMuonID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsTauID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJEC",
    #"HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJECUncertaintySplit",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJetID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsBTaggedJetID",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_et",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsSvfit",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsTauES",
    "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsMVATestMethods"
  ]
  for include_file in includes:
    analysis_config_module = importlib.import_module(include_file)
    config += analysis_config_module.build_config(nickname)
  
  # explicit configuration
  config["Channel"] = "ET"
  config["MinNElectrons"] = 1
  config["MinNTaus"] = 1
  # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
  if re.search("Run2016|Summer16", nickname): config["HltPaths"] = [
          "HLT_Ele25_eta2p1_WPTight_Gsf"]
  elif isEmbedded: config["HltPaths"] = [
          ""]
  config["HLTBranchNames"] = ["trg_singleelectron:HLT_Ele25_eta2p1_WPTight_Gsf_v"]
  config["NoHltFiltering"] = True if isEmbedded else False
  config["TauID"] = "TauIDRecommendation13TeV"
  config["TauUseOldDMs"] = True
  config["ElectronLowerPtCuts"] = ["26.0"]
  config["ElectronUpperAbsEtaCuts"] = ["2.1"]
  config["TauLowerPtCuts"] = ["30.0"]
  config["TauUpperAbsEtaCuts"] = ["2.3"]
  config["TriggerObjectLowerPtCut"] = -1.0
  config["DiTauPairMinDeltaRCut"] = 0.5
  config["DiTauPairIsTauIsoMVA"] = True
  config["DiTauPairLepton1LowerPtCuts"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v:26.0"]
  config["DiTauPairHltPathsWithoutCommonMatchRequired"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v"]
  config["DiTauPairNoHLT"] = True if isEmbedded else False
  config["DiTauPairHLTLast"] = True
  config["EventWeight"] = "eventWeight"
  config["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
  config["RooWorkspaceWeightNames"] = [
    "0:triggerWeight",
    "0:idIsoWeight",
    "0:trackWeight"
  ]
  config["RooWorkspaceObjectNames"] = [
    "0:e_trgEle25eta2p1WPTight_desy_ratio",
    "0:e_idiso0p1_desy_ratio",
    "0:e_trk_ratio"
  ]
  config["RooWorkspaceObjectArguments"] = [
    "0:e_pt,e_eta",
    "0:e_pt,e_eta",
    "0:e_pt,e_eta"
  ]
  config["TriggerEfficiencyData"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele25WPTight_eff.root"]
  config["TriggerEfficiencyMc"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele25WPTight_eff.root"]
  config["IdentificationEfficiencyData"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p1_eff.root"]
  config["IdentificationEfficiencyMc"] = [
    "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p1_eff.root"]
  
  config["IdentificationEfficiencyMode"] = "multiply_weights"
  config["TauTauRestFrameReco"] = "collinear_approximation"
  config["TriggerEfficiencyMode"] = "multiply_weights"
  config["EleTauFakeRateWeightFile"] = ["1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/antiElectronDiscrMVA6FakeRateWeights.root"]
  
  config["ElectronTriggerFilterNames"] = ["HLT_Ele25_eta2p1_WPTight_Gsf_v:hltEle25erWPTightGsfTrackIsoFilter"]
  
  config["InvalidateNonMatchingElectrons"] = False
  config["InvalidateNonMatchingMuons"] = False
  config["InvalidateNonMatchingTaus"] = False
  config["InvalidateNonMatchingJets"] = False
  config["DirectIso"] = True
  config["UseUWGenMatching"] = "true"
  
  config["Quantities"] = importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.fourVectorQuantities").build_list()
  config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.syncQuantities").build_list())
  config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.svfitSyncQuantities").build_list())
  #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.splitJecUncertaintyQuantities").build_list())
  config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities").build_list())
  config["Quantities"].extend([
      "nVetoElectrons",
      "nLooseElectrons",
      "nLooseMuons",
      "nDiTauPairCandidates",
      "nAllDiTauPairCandidates",
      "trg_singleelectron",
      "lep1ErrD0",
      "lep1ErrDz",
      "lep2ErrD0",
      "lep2ErrDz",
      "PVnDOF",
      #"PVchi2",
      "drel0_1",
      "drel0_2",
      "drelZ_1",
      "drelZ_2",
      "idisoweight_1",
      #"htxs_stage0cat",
      #"htxs_stage1cat",
      "flagMETFilter",
      "pt_ttjj"
  ])
  if re.search("HToTauTauM125", nickname):
    config["Quantities"].extend([
      "htxs_stage0cat",
      "htxs_stage1cat"
    ])
  if isGluonFusion:
    config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.ggHNNLOQuantities").build_list())

  
  config["OSChargeLeptons"] = True
  
  config["Processors"] = [                                    "producer:HltProducer",
                                                              "filter:HltFilter",
                                                              "producer:MetSelector",
                                                              "producer:ValidElectronsProducer",
                                                              "filter:ValidElectronsFilter",
                                                              "producer:ElectronTriggerMatchingProducer",
                                                              "filter:MinElectronsCountFilter",
                                                              "producer:ValidMuonsProducer"]
  if not isData:                 config["Processors"].append( "producer:TauCorrectionsProducer")
  config["Processors"].extend((                               "producer:ValidTausProducer",
                                                              "filter:ValidTausFilter",
                                                              "producer:TauTriggerMatchingProducer",
                                                              "filter:MinTausCountFilter",
                                                              "producer:ValidETPairCandidatesProducer",
                                                              "filter:ValidDiTauPairCandidatesFilter",
                                                              "producer:HttValidVetoElectronsProducer",
                                                              "producer:HttValidLooseElectronsProducer",
                                                              "producer:HttValidLooseMuonsProducer",
                                                              "producer:Run2DecayChannelProducer",
                                                              "producer:DiVetoElectronVetoProducer",
                                                              "producer:TaggedJetCorrectionsProducer",
                                                              "producer:ValidTaggedJetsProducer",
                                                              "producer:ValidBTaggedJetsProducer",
                                                              "producer:GroupedJetUncertaintyShiftProducer"))
                                                              #"producer:TaggedJetUncertaintyShiftProducer"))
  if not isData:                 config["Processors"].append( "producer:MetCorrector") #"producer:MvaMetCorrector"
  config["Processors"].extend((                               "producer:TauTauRestFrameSelector",
                                                              "producer:DiLeptonQuantitiesProducer",
                                                              "producer:DiJetQuantitiesProducer"))
  if not isData:                 config["Processors"].extend(("producer:SimpleEleTauFakeRateWeightProducer",
							      "producer:SimpleMuTauFakeRateWeightProducer"))
  if isTTbar:                    config["Processors"].append( "producer:TopPtReweightingProducer")
  if isDY:                       config["Processors"].append( "producer:ZPtReweightProducer")
  config["Processors"].extend((                               "filter:MinimalPlotlevelFilter",
                                                              "producer:SvfitProducer",
                                                              "producer:ImpactParameterCorrectionsProducer")) #"producer:MVATestMethodsProducer"
  if not isData:                 config["Processors"].append( "producer:RooWorkspaceWeightProducer")
  config["Processors"].append(                                "producer:EventWeightProducer")
  if isGluonFusion:              config["Processors"].append( "producer:SMggHNNLOProducer")
  
  
  config["AddGenMatchedParticles"] = True
  config["AddGenMatchedTaus"] = True
  config["AddGenMatchedTauJets"] = True
  config["BranchGenMatchedElectrons"] = True
  config["BranchGenMatchedTaus"] = True
  config["Consumers"] = ["KappaLambdaNtupleConsumer",
                         "cutflow_histogram"]
                         #"SvfitCacheConsumer"]
                         #"CutFlowTreeConsumer",
                         #"KappaElectronsConsumer",
                         #"KappaTausConsumer",
                         #"KappaTaggedJetsConsumer",
                         #"RunTimeConsumer",
                         #"PrintEventsConsumer"
  
  
  # pipelines - systematic shifts
  return ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.nominal").build_config(nickname)) + \
         ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.JECunc_shifts").build_config(nickname)) + \
         ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.METunc_shifts").build_config(nickname)) + \
         ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.tauESperDM_shifts").build_config(nickname)) + \
         ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.tauEleFakeESperDM_shifts").build_config(nickname)) + \
         ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.tauJetFakeESIncl_shifts").build_config(nickname)) + \
         ACU.apply_uncertainty_shift_configs('et', config, importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.btagging_shifts").build_config(nickname))
	def build_config(self, nickname, *args, **kwargs): #Maybe change this the arguments to process/year and DATA/MC

		datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(os.path.expandvars("$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

		# define frequently used conditions
		isEmbedded = datasetsHelper.isEmbedded(nickname)
		isData = datasetsHelper.isData(nickname) and (not isEmbedded)

		ElectronID_config = sEID.Electron_ID(nickname)
		ElectronID_config.looseElectron_ID(nickname) 		#append the config for loose electron ID because it is used
		self.update(ElectronID_config)

		MuonID_config = sMID.Muon_ID(nickname)
		MuonID_config.looseMuon_ID(nickname) 		#append the config for loose Muon ID because it is used
		self.update(MuonID_config)

		TauID_config = sTID.Tau_ID(nickname)			#here loose is not appended since loose tau ID is not used
		self.update(TauID_config)

		JEC_config = sJEC.JEC(nickname)  #Is allready in baseconfig, for now leave it in; possibly remove it
		self.update(JEC_config)

		JECUncertaintySplit_config = sJECUS.JECUncertaintySplit(nickname)
		self.update(JECUncertaintySplit_config)

		JetID_config = sJID.Jet_ID(nickname)
		self.update(JetID_config)

		BTaggedJet_config = sBTJID.BTaggedJet_ID(nickname)
		self.update(BTaggedJet_config)

		Svfit_config = sSvfit.Svfit(nickname)
		self.update(Svfit_config)

		MinimalPlotlevelFilter_config = sMPlF.MinimalPlotlevelFilter()
		MinimalPlotlevelFilter_config.em()
		self.update(MinimalPlotlevelFilter_config)
		
		MVATestMethods_config = sMVATM.MVATestMethods()
		self.update(MVATestMethods_config)

		self["Channel"] = "EM"
		self["MinNElectrons"] = 1
		self["MinNMuons"] = 1
		self["HltPaths_comment"] = "The first path must be one with the higher pt cut on the electron. The second and last path must be one with the higher pt cut on the muon. Corresponding Pt cuts are implemented in the Run2DecayChannelProducer."

		self["NoHltFiltering"] = False #*default
		self["DiTauPairLepton1LowerPtCuts"] = [								     # **default
			"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:24.0"
		]

		self["DiTauPairLepton2LowerPtCuts"] = [								# ***default
			"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:24.0",
			"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
		]
		self["DiTauPairNoHLT"] = False
		
		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["HltPaths"] = [
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL",
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
			]
			self["DiTauPairLepton1LowerPtCuts"] = [							#**
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:18.0"
			]
			self["DiTauPairLepton2LowerPtCuts"] = [
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL_v:18.0"
			]

		elif re.search("Run2016(B|C|D|E|F)|Spring16|Summer16", nickname):
			self["HltPaths"] = [
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
			]

		elif re.search("Run2016(G|H)", nickname):
			self["HltPaths"] = [
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ"
			]
			self["DiTauPairLepton1LowerPtCuts"] = [							#**
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
			]

		elif re.search("Embedding(2016|MC)", nickname):
			self["HltPaths"] = []
			self["NoHltFiltering"] = True 								#*if "Embedding(2016|MC)"
			self["DiTauPairLepton1LowerPtCuts"] = [                                         	 #**
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:-1.0",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:-1.0"
			]
			self["DiTauPairLepton2LowerPtCuts"] = [							#***
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:-1.0",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:-1.0"
			]
			self["DiTauPairNoHLT"] = True
			self["LowerCutHardLepPt"] = 24.0
		
		self["ElectronLowerPtCuts"] = [
			"13.0"
		]
		self["ElectronUpperAbsEtaCuts"] = [
			"2.5"
		]
		self["MuonLowerPtCuts"] = [
			"10.0"
		]
		self["MuonUpperAbsEtaCuts"] = [
			"2.4"
		]
		self["DeltaRTriggerMatchingElectrons"] = 0.4
		self["DeltaRTriggerMatchingMuons"] = 0.4
		self["DiTauPairMinDeltaRCut"] = 0.3
		self["DiTauPairIsTauIsoMVA"] = True

		self["EventWeight"] = "eventWeight"
		self["RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5_1.root"
		self["RooWorkspaceWeightNames"] = [
			"0:idIsoWeight",
			"0:emuQcdOsssWeight",
			"0:emuQcdOsssRateUpWeight",
			"0:emuQcdOsssRateDownWeight",
			"0:emuQcdOsssShapeUpWeight",
			"0:emuQcdOsssShapeDownWeight",
			"0:emuQcdExtrapUpWeight",
			"0:emuQcdExtrapDownWeight",			
			"1:idIsoWeight",
			"1:emuQcdOsssWeight",
			"1:emuQcdOsssRateUpWeight",
			"1:emuQcdOsssRateDownWeight",
			"1:emuQcdOsssShapeUpWeight",
			"1:emuQcdOsssShapeDownWeight",
			"1:emuQcdExtrapUpWeight",
			"1:emuQcdExtrapDownWeight"							
		]
		self["RooWorkspaceObjectNames"] = [
			"0:e_idiso0p15_desy_ratio",
			"0:em_qcd_osss_binned",
			"0:em_qcd_osss_rateup_binned",
			"0:em_qcd_osss_ratedown_binned",
			"0:em_qcd_osss_shapeup_binned",
			"0:em_qcd_osss_shapedown_binned",
			"0:em_qcd_extrap_up",
			"0:em_qcd_extrap_down",			
			"1:m_idiso0p20_desy_ratio",
			"1:em_qcd_osss_binned",
			"1:em_qcd_osss_rateup_binned",
			"1:em_qcd_osss_ratedown_binned",
			"1:em_qcd_osss_shapeup_binned",
			"1:em_qcd_osss_shapedown_binned",
			"1:em_qcd_extrap_up",
			"1:em_qcd_extrap_down",				
		]
		self["RooWorkspaceObjectArguments"] = [
			"0:e_pt,e_eta",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"0:njets,dR,e_pt,m_pt",
			"1:m_pt,m_eta",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt",
			"1:njets,dR,e_pt,m_pt"
		]

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["TriggerEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Electron_Ele12_fall15.root",         	 #2 times 0:... and 1:...
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Electron_Ele17_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Muon_Mu8_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2015_Muon_Mu17_fall15.root"
			]

			self["TriggerEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele12_fall15.root",
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele17_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu8_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu17_fall15.root"
			]

			self["IdentificationEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p15_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
			]
			self["IdentificationEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso0p15_fall15.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso0p15_fall15.root"
			]

		else:
			self["TriggerEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele12leg_eff.root",      		 #2 times 0:... and 1:...
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele23leg_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu8leg_2016BtoH_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu23leg_2016BtoH_eff.root"
			]
			self["TriggerEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele12leg_eff.root",
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele23leg_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu8leg_2016BtoH_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu23leg_2016BtoH_eff.root"
			]
		
			self["IdentificationEfficiencyData"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p15_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
			]
			self["IdentificationEfficiencyMc"] = [
				"0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p15_eff.root",
				"1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
			]

		self["TriggerEfficiencyMode"] = "correlate_triggers"
		self["IdentificationEfficiencyMode"] = "multiply_weights"
		self["TauTauRestFrameReco"] = "collinear_approximation"

		if re.search("(Fall15MiniAODv2|Run2015D|Embedding2015)", nickname):
			self["ElectronTriggerFilterNames"] = [
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu17TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle17CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter"
			]
			self["MuonTriggerFilterNames"] = [
				"HLT_Mu17_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu17TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered17",
				"HLT_Mu8_TrkIsoVVL_Ele17_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle17CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8"
			]

		elif re.search("Run2016(B|C|D|E|F)|Spring16|Summer16", nickname):
			self["ElectronTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter"
			]
			self["MuonTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8"
			]

		elif re.search("Run2016(G|H)", nickname):
			self["ElectronTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLDZFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLDZFilter"
			]
			self["MuonTriggerFilterNames"] = [
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
				"HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLDZFilter",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8",
				"HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLDZFilter"
			]

		self["InvalidateNonMatchingElectrons"] = True
		self["InvalidateNonMatchingMuons"] = True
		self["InvalidateNonMatchingTaus"] = False
		self["InvalidateNonMatchingJets"] = False
		self["DirectIso"] = True
	
		self["OSChargeLeptons"] = True
		self["SvfitKappaParameter"] = 3.0

		self["AddGenMatchedParticles"] = True
		self["BranchGenMatchedElectrons"] = True
		self["BranchGenMatchedMuons"] = True
		self["Consumers"] = [
			"KappaLambdaNtupleConsumer",
			"cutflow_histogram",
			"SvfitCacheConsumer",
			"#CutFlowTreeConsumer",
			"#KappaElectronsConsumer",
			"#KappaMuonsConsumer",
			"#KappaTaggedJetsConsumer",
			"#RunTimeConsumer",
			"#PrintEventsConsumer",
			"#PrintGenParticleDecayTreeConsumer"
		]

		quantities_dict = quantities.quantities() 
		quantities_dict.build_quantities(nickname, channel = self["Channel"])

		#put rest of quantities in CPQuantities.py?

		quantities_dict["Quantities"] += [
				"nLooseElectrons",
				"nLooseMuons",
				"nDiTauPairCandidates",
				"nAllDiTauPairCandidates"
			]

		if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += quantities_dict.lheWeightsDYQuantities()
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += quantities_dict.svfitSyncQuantities()
		elif re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("Embedding2016", nickname):
			quantities_dict["Quantities"] += [
				"tauSpinnerValidOutputs",
				"tauSpinnerPolarisation",
			]
		elif re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
			quantities_dict["Quantities"] += [
				"jetCorrectionWeight"
			]
		self.update(copy.deepcopy(quantities_dict))

		self["Processors"] = [
				"producer:HltProducer",
				"filter:HltFilter",
				"producer:MetSelector",
				################## special for each channel in et mt tt em.
				"producer:ValidElectronsProducer",
				"filter:ValidElectronsFilter",
				"producer:ElectronTriggerMatchingProducer",
				"filter:MinElectronsCountFilter",
				"producer:ValidMuonsProducer",
				"filter:ValidMuonsFilter",
				"producer:MuonTriggerMatchingProducer",
				"filter:MinMuonsCountFilter",
				"producer:ValidTausProducer",
				"producer:ValidEMPairCandidatesProducer",
				"filter:ValidDiTauPairCandidatesFilter",
				"producer:HttValidLooseMuonsProducer",
				##################
				"producer:Run2DecayChannelProducer",          
				"producer:TaggedJetCorrectionsProducer",
				"producer:ValidTaggedJetsProducer",
				"producer:ValidBTaggedJetsProducer",	
				"producer:TauTauRestFrameSelector",
				"producer:DiLeptonQuantitiesProducer",
				"producer:DiJetQuantitiesProducer",
				"producer:HttValidLooseElectronsProducer"
				]

		if re.search("(Spring16|Summer16|Run2016)", nickname):
			self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["producer:TaggedJetUncertaintyShiftProducer"]
			self["Processors"]+= ["producer:MetFilterProducer"]
			
			if re.search("Run2016", nickname):
				#self["Processors"] += ["producer:MVATestMethodsProducer"]
						
				self["Processors"] += ["producer:SimpleFitProducer"]
				self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				self["Processors"] += ["filter:MinimalPlotlevelFilter"]
				self["Processors"] += ["producer:SvfitProducer"]
				self["Processors"] += ["producer:SvfitM91Producer"]
				self["Processors"] += ["producer:SvfitM125Producer"]

				self["Processors"] += ["producer:MELAProducer"]
				self["Processors"] += ["producer:MELAM125Producer"]


				#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

			else:
				#self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:ElectronCorrectionsProducer"] #channel dependent
				self["Processors"] += ["producer:TriggerWeightProducer"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:RooWorkspaceWeightProducer"]
							
				if re.search("(LFV).*(?=(Spring16|Summer16))", nickname):
					self["Processors"] += [
						"producer:ZPtReweightProducer"
						#"filter:MinimalPlotlevelFilter"
					]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:LFVJetCorrection2016Producer"]

				else:              
					self["Processors"] += ["filter:MinimalPlotlevelFilter"]
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

					if re.search("(DY.?JetsToLL).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += ["producer:ZPtReweightProducer"]			

						self["Processors"] += ["producer:SimpleFitProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

					elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=(Spring16|Summer16))", nickname):
						self["Processors"] += [
							"producer:TopPtReweightingProducer"
						] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:GenMatchedTauCPProducer"]
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]
						#self["Processors"] += ["producer:MadGraphReweightingProducer"]
					else:
						self["Processors"] += [	"producer:TopPtReweightingProducer"] 
						#self["Processors"] += ["producer:MVATestMethodsProducer"]
						self["Processors"] += ["producer:SimpleFitProducer"]				
						self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]
				
						#self["Processors"] += ["producer:TauPolarisationTmvaReader"]

		elif re.search("(Fall15|Run2015)", nickname):
			#self["Processors"] += ["producer:RefitVertexSelector"]
			self["Processors"] += ["producer:RecoTauCPProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitProducer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSvfitM91Producer"]
			self["Processors"] += ["producer:PolarisationQuantitiesSimpleFitProducer"]
			self["Processors"] += ["filter:MinimalPlotlevelFilter"]
			self["Processors"] += ["producer:MvaMetSelector"]

			
			if re.search("Run2015", nickname):
				pass
				#self["Processors"] += ["producer:SimpleFitProducer"]
			
				#self["Processors"] += ["producer:SvfitProducer"]
				#self["Processors"] += ["producer:SvfitM91Producer"]
				#self["Processors"] += ["producer:SvfitM125Producer"]

				#self["Processors"] += ["producer:MELAProducer"]
				#self["Processors"] += ["producer:MELAM125Producer"]
			else:
				self["Processors"] += ["producer:MvaMetCorrector"]
				self["Processors"] += ["producer:MetCorrector"]
				self["Processors"] += ["producer:RecoElectronGenParticleMatchingProducer"] #if you grep this, it is already in globalprocessors
				self["Processors"] += ["producer:RecoMuonGenParticleMatchingProducer"]
				self["Processors"] += ["producer:MatchedLeptonsProducer"]
				#self["Processors"] += ["producer:TauCorrectionsProducer"]
				self["Processors"] += ["producer:TriggerWeightProducer",
					"producer:IdentificationWeightProducer",
					"producer:EleTauFakeRateWeightProducer"
				]

				if re.search("(DY.?JetsToLL).*(?=Fall15)", nickname):

					self["Processors"] += ["producer:ZPtReweightProducer"]			
					#self["Processors"] += ["producer:SimpleFitProducer"]
					self["Processors"] += ["producer:GenMatchedTauCPProducer"]
					self["Processors"] += ["producer:GenMatchedPolarisationQuantitiesProducer"]

				elif re.search("(HToTauTau|H2JetsToTauTau|Higgs).*(?=Fall15)",nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

				elif re.search("^((?!(DY.?JetsToLL|HToTauTau|H2JetsToTauTau|Higgs)).)*Fall15", nickname):
					self["Processors"] += ["producer:SvfitProducer"]
					self["Processors"] += ["producer:SvfitM91Producer"]
					self["Processors"] += ["producer:SvfitM125Producer"]

					self["Processors"] += ["producer:MELAProducer"]
					self["Processors"] += ["producer:MELAM125Producer"]

		self["Processors"] += ["producer:EventWeightProducer"]
		self["Processors"] = list(set(self["Processors"]))
		processorOrderingkey = processorOrdering.processors_ordered(channel = self["Channel"])
		ordered_processors = processorOrderingkey.order_processors(self["Processors"]) 
		self["Processors"] = copy.deepcopy(ordered_processors)
Exemple #28
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLL", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsKappa",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.lheWeightAssignment",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsSampleStitchingWeights",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.globalProcessors"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["SkipEvents"] = 0
    config["EventCount"] = -1
    config["InputIsData"] = "true" if isData else "false"

    config["LumiWhiteList"] = [7582]
    config["EventWhitelist"] = [1473388]

    BosonPdgIds = {
        "DY.?JetsToLL|EWKZ2Jets|Embedding(2016|MC)": [23],
        "^(GluGlu|GluGluTo|VBF|Wminus|Wplus|Z)(HToTauTau|H2JetsToTauTau)":
        [25],
        "W.?JetsToLN|EWKW": [24],
        "SUSY(BB|GluGlu|GluGluTo)(BB)?HToTauTau": [25, 35, 36]
    }
    config["BosonPdgIds"] = [0]
    for key, pdgids in BosonPdgIds.items():
        if re.search(key, nickname): config["BosonPdgIds"] = pdgids

    config["BosonStatuses"] = [11, 62]
    config["DeltaRMatchingRecoElectronGenParticle"] = 0.2
    config["DeltaRMatchingRecoElectronGenTau"] = 0.2
    config["DeltaRMatchingRecoMuonGenParticle"] = 0.2
    config["DeltaRMatchingRecoMuonGenTau"] = 0.2
    config["DeltaRMatchingRecoTauGenParticle"] = 0.2
    config["DeltaRMatchingRecoTauGenTau"] = 0.2
    config["RecoElectronMatchingGenParticlePdgIds"] = [11, 13]
    config["RecoMuonMatchingGenParticlePdgIds"] = [11, 13]
    config["RecoTauMatchingGenParticlePdgIds"] = [11, 13]
    config["RecoElectronMatchingGenParticleMatchAllElectrons"] = "true"
    config["RecoMuonMatchingGenParticleMatchAllMuons"] = "true"
    config["RecoTauMatchingGenParticleMatchAllTaus"] = "true"
    config["MatchAllElectronsGenTau"] = "true"
    config["MatchAllMuonsGenTau"] = "true"
    config["MatchAllTausGenTau"] = "true"
    config["MatchGenTauDecayMode"] = "true"
    config["UpdateMetWithCorrectedLeptons"] = "true"
    config["TopPtReweightingStrategy"] = "Run1"
    '''config["MetFilter"] = [
        "Flag_HBHENoiseFilter",
        "Flag_HBHENoiseIsoFilter",
        "Flag_EcalDeadCellTriggerPrimitiveFilter",
        "Flag_goodVertices",
        "Flag_globalTightHalo2016Filter",
        "Flag_BadPFMuonFilter",
        "Flag_BadChargedCandidateFilter"
  ]
  if isData:
    config["MetFilter"].extend((
        "Flag_eeBadScFilter",
        "!Flag_duplicateMuons",
        "!Flag_badMuons"
    ))
  else:
    config["MetFilter"].extend((
        "!Flag_badGlobalMuonTaggerMAOD",
        "!Flag_cloneGlobalMuonTaggerMAOD"
    ))'''
    config["MetFilterToFlag"] = [
        "Flag_HBHENoiseFilter", "Flag_HBHENoiseIsoFilter",
        "Flag_EcalDeadCellTriggerPrimitiveFilter", "Flag_goodVertices",
        "Flag_globalTightHalo2016Filter", "Flag_BadPFMuonFilter",
        "Flag_BadChargedCandidateFilter"
    ]
    if isData:
        config["MetFilterToFlag"].append("Flag_eeBadScFilter")
        config["MetFilter"] = ["!Flag_duplicateMuons", "!Flag_badMuons"]
    else:
        config["MetFilter"] = [
            "!Flag_badGlobalMuonTaggerMAOD", "!Flag_cloneGlobalMuonTaggerMAOD"
        ]

    config["OutputPath"] = "output.root"

    if isData or isEmbedded: config["PileupWeightFile"] = "not needed"
    elif re.search(".*Summer16", nickname):
        config[
            "PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2016_271036-284044_13TeVMoriond17_23Sep2016ReReco_69p2mbMinBiasXS.root"
    else:
        config[
            "PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2015_246908-260627_13TeVFall15MiniAODv2_PromptReco_69mbMinBiasXS.root"

    config[
        "BTagScaleFactorFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/CSVv2_moriond17_BtoH.csv" if re.search(
            "Summer16", nickname
        ) else "$CMSSW_BASE/src/Artus/KappaAnalysis/data/CSVv2_76X.csv"
    config[
        "BTagEfficiencyFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/tagging_efficiencies_moriond2017.root" if re.search(
            "Summer16", nickname
        ) else "$CMSSW_BASE/src/Artus/KappaAnalysis/data/tagging_efficiencies.root"

    config[
        "MetRecoilCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/TypeI-PFMet_Run2016BtoH.root"
    config[
        "MetShiftCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/MEtSys.root"
    config[
        "MvaMetShiftCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/MEtSys.root"
    config[
        "MvaMetRecoilCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/MvaMET_2016BCD.root"
    config["MetCorrectionMethod"] = "meanResolution"
    #config["ZptReweightProducerWeights"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/zpt/zpt_weights_2016_BtoH.root"
    config[
        "ZptRooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
    config["DoZptUncertainties"] = False

    config["ChooseMvaMet"] = False

    if isData or isEmbedded:
        if re.search("Run2016|Embedding2016", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt"
            ]
        elif re.search("Run2015(C|D)|Embedding2015", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_13TeV_16Dec2015ReReco_Collisions15_25ns_JSON_v2.txt"
            ]
        elif re.search("Run2015B", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_13TeV_16Dec2015ReReco_Collisions15_50ns_JSON_v2.txt"
            ]

    if re.search("Fall15MiniAODv2", nickname):
        config["SimpleMuTauFakeRateWeightLoose"] = [1.0, 1.0, 1.0, 1.0, 1.0]
        config["SimpleMuTauFakeRateWeightTight"] = [1.0, 1.0, 1.0, 1.0, 1.0]
        config["SimpleEleTauFakeRateWeightVLoose"] = [1.02, 1.11]
        config["SimpleEleTauFakeRateWeightTight"] = [1.80, 1.30]
    else:
        config["SimpleMuTauFakeRateWeightLoose"] = [
            1.22, 1.12, 1.26, 1.22, 2.39
        ]
        config["SimpleMuTauFakeRateWeightTight"] = [
            1.47, 1.55, 1.33, 1.72, 2.50
        ]
        config["SimpleEleTauFakeRateWeightVLoose"] = [1.21, 1.38]
        config["SimpleEleTauFakeRateWeightTight"] = [1.40, 1.90]

    if re.search("GluGluHToTauTauM125", nickname):
        config[
            "ggHNNLOweightsRootfile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/NNLOWeights/NNLOPS_reweight.root"
        if "powheg" in nickname:
            config["Generator"] = "powheg"
        elif "amcatnlo" in nickname:
            config["Generator"] = "amcatnlo"

    # pipelines - channels including systematic shifts
    config["Pipelines"] = jsonTools.JsonDict()
    #config["Pipelines"] += importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.ee").build_config(nickname)
    #config["Pipelines"] += importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.em").build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.et"
    ).build_config(nickname)
    #config["Pipelines"] += importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.mm").build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.mt"
    ).build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.tt"
    ).build_config(nickname)
    #config["Pipelines"] += importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.inclusive").build_config(nickname)

    return config
Exemple #29
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)
    isSignal = re.search("HToTauTau", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsVetoElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsTauES",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.settingsMinimalPlotlevelFilter_et"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "ET"
    config["MinNElectrons"] = 1
    config["MinNTaus"] = 1
    # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer..
    if re.search("(Run201|Embedding201|Summer1|Fall1)", nickname):
        config["HltPaths"] = [
            "HLT_IsoMu24", "HLT_IsoMu27",
            "HLT_IsoMu20_eta2p1_LooseChargedIsoPFTau27_eta2p1_CrossL1",
            "HLT_IsoMu24_eta2p1_LooseChargedIsoPFTau20_SingleL1",
            "HLT_Ele32_WPTight_Gsf", "HLT_Ele35_WPTight_Gsf",
            "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1",
            "HLT_DoubleMediumChargedIsoPFTau35_Trk1_eta2p1_Reg",
            "HLT_DoubleTightChargedIsoPFTau35_Trk1_TightID_eta2p1_Reg",
            "HLT_DoubleMediumChargedIsoPFTau40_Trk1_TightID_eta2p1_Reg",
            "HLT_DoubleTightChargedIsoPFTau40_Trk1_eta2p1_Reg",
            "HLT_MediumChargedIsoPFTau180HighPtRelaxedIso_Trk50_eta2p1",
            "HLT_Mu12_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ"
        ]

    config["TauID"] = "TauIDRecommendation13TeV"
    config["TauUseOldDMs"] = True
    config["ElectronLowerPtCuts"] = ["10.0"]
    config["ElectronUpperAbsEtaCuts"] = ["2.1"]
    config["TauLowerPtCuts"] = ["30.0"]
    config["TauUpperAbsEtaCuts"] = ["2.3"]
    config["DiTauPairMinDeltaRCut"] = 0.5
    config["DeltaRTriggerMatchingTaus"] = 0.5
    config["DeltaRTriggerMatchingElectrons"] = 0.5
    config["DiTauPairIsTauIsoMVA"] = True
    config["DiTauPairLepton1LowerPtCuts"] = [
        "HLT_Ele32_WPTight_Gsf_v:34.0",
        "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v:26.0",
        "HLT_Ele35_WPTight_Gsf_v:37.0"
    ]
    config["DiTauPairLepton2LowerPtCuts"] = [
        "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v:33.0"
    ]
    config["DiTauPairNoHLT"] = False
    config["DiTauPairHLTLast"] = True
    config["HLTBranchNames"] = [
        "trg_singlemuon_lowpt:HLT_IsoMu24_v", "trg_singlemuon:HLT_IsoMu27_v",
        "trg_muontau_lowptmu:HLT_IsoMu20_eta2p1_LooseChargedIsoPFTau27_eta2p1_CrossL1_v",
        "trg_muontau_lowpttau:HLT_IsoMu24_eta2p1_LooseChargedIsoPFTau20_SingleL1_v",
        "trg_singleelectron_lowpt:HLT_Ele32_WPTight_Gsf_v",
        "trg_singleelectron:HLT_Ele35_WPTight_Gsf_v",
        "trg_electrontau:HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v",
        "trg_doubletau_lowpt_mediso:HLT_DoubleMediumChargedIsoPFTau35_Trk1_eta2p1_Reg_v",
        "trg_doubletau_lowpt:HLT_DoubleTightChargedIsoPFTau35_Trk1_TightID_eta2p1_Reg_v",
        "trg_doubletau_mediso:HLT_DoubleMediumChargedIsoPFTau40_Trk1_TightID_eta2p1_Reg_v",
        "trg_doubletau:HLT_DoubleTightChargedIsoPFTau40_Trk1_eta2p1_Reg_v",
        "trg_singletau_leading:HLT_MediumChargedIsoPFTau180HighPtRelaxedIso_Trk50_eta2p1_v",
        "trg_singletau_trailing:HLT_MediumChargedIsoPFTau180HighPtRelaxedIso_Trk50_eta2p1_v",
        "trg_muonelectron_lowptmu:HLT_Mu12_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v",
        "trg_muonelectron_lowpte:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v"
    ]
    config["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
        "HLT_IsoMu24_v", "HLT_IsoMu27_v", "HLT_Ele32_WPTight_Gsf_v",
        "HLT_Ele35_WPTight_Gsf_v",
        "HLT_MediumChargedIsoPFTau180HighPtRelaxedIso_Trk50_eta2p1_v"
    ]
    config["UsingOnlyFirstLeptonPerHLTBranchNames"] = [
        "trg_singletau_leading:1",
        "trg_singletau_trailing:0",
    ]
    config[
        "TauTrigger2017Input"] = "$CMSSW_BASE/src/TauTriggerSFs2017/TauTriggerSFs2017/data/tauTriggerEfficiencies2017.root"
    config["TauTrigger2017WorkingPoint"] = "tight"
    config["TauTrigger2017EfficiencyWeightNames"] = [
        "1:crossTriggerMCEfficiencyWeight",
        "1:crossTriggerDataEfficiencyWeight",
    ]
    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v17_1.root"
    config["RooWorkspaceWeightNames"] = [
        "0:crossTriggerMCEfficiencyWeight",
        "0:crossTriggerDataEfficiencyWeight",
    ]
    config["RooWorkspaceObjectNames"] = [
        "0:e_trg_EleTau_Ele24Leg_desy_mc",
        "0:e_trg_EleTau_Ele24Leg_desy_data",
    ]
    config["RooWorkspaceObjectArguments"] = [
        "0:e_pt,e_eta",
        "0:e_pt,e_eta",
    ]
    config["FakeFaktorFiles"] = [
        "inclusive:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/tight/et/inclusive/fakeFactors_20170628_tight.root",
        "nobtag_tight:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/tight/et/nobtag_tight/fakeFactors_20170628_tight.root",
        "nobtag_loosemt:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/tight/et/nobtag_loosemt/fakeFactors_20170628_tight.root",
        "btag_tight:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/tight/et/btag_tight/fakeFactors_20170628_tight.root",
        "btag_loosemt:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/fakeFactorWeights/tight/et/btag_loosemt/fakeFactors_20170628_tight.root"
    ]
    config["EventWeight"] = "eventWeight"
    config["TauTauRestFrameReco"] = "collinear_approximation"
    config["ElectronTriggerFilterNames"] = [
        "HLT_Ele32_WPTight_Gsf_v:hltEle32WPTightGsfTrackIsoFilter",
        "HLT_Ele35_WPTight_Gsf_v:hltEle35noerWPTightGsfTrackIsoFilter",
        "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v:hltEle24erWPTightGsfTrackIsoFilterForTau",
        "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v:hltOverlapFilterIsoEle24WPTightGsfLooseIsoPFTau30"
    ]
    config["TauTriggerFilterNames"] = [
        "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v:hltSelectedPFTau30LooseChargedIsolationL1HLTMatched",
        "HLT_Ele24_eta2p1_WPTight_Gsf_LooseChargedIsoPFTau30_eta2p1_CrossL1_v:hltOverlapFilterIsoEle24WPTightGsfLooseIsoPFTau30",
        "HLT_MediumChargedIsoPFTau180HighPtRelaxedIso_Trk50_eta2p1_v:hltPFTau180TrackPt50LooseAbsOrRelMediumHighPtRelaxedIsoIso",
        "HLT_MediumChargedIsoPFTau180HighPtRelaxedIso_Trk50_eta2p1_v:hltSelectedPFTau180MediumChargedIsolationL1HLTMatched"
    ]
    config["BTagWPs"] = ["medium"]
    config["InvalidateNonMatchingElectrons"] = True
    config["InvalidateNonMatchingMuons"] = False
    config["InvalidateNonMatchingTaus"] = True
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.syncQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.zptQuantities"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.lheWeights"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.Includes.fakeFactorWeightQuantities"
        ).build_list())
    config["Quantities"].extend(["had_gen_match_pT_1", "had_gen_match_pT_2"])

    config["OSChargeLeptons"] = True
    config["TopPtReweightingStrategy"] = "Run2"

    config["Processors"] = [
    ]  # if (isData or isEmbedded) else ["producer:ElectronCorrectionsProducer"]
    config["Processors"].extend(
        ("producer:HttValidLooseElectronsProducer",
         "producer:HttValidLooseMuonsProducer", "producer:HltProducer",
         "producer:MetSelector", "producer:ValidElectronsProducer",
         "filter:ValidElectronsFilter",
         "producer:ElectronTriggerMatchingProducer",
         "filter:MinElectronsCountFilter",
         "producer:HttValidVetoElectronsProducer",
         "producer:ValidMuonsProducer"))
    #if not isData:                 config["Processors"].append( "producer:TauCorrectionsProducer")
    config["Processors"].extend((
        "producer:ValidTausProducer",
        "filter:ValidTausFilter",
        "producer:TauTriggerMatchingProducer",
        "filter:MinTausCountFilter",
        "producer:ValidETPairCandidatesProducer",
        "filter:ValidDiTauPairCandidatesFilter",
        "producer:Run2DecayChannelProducer",
        "producer:DiVetoElectronVetoProducer",
        #                                                            "producer:TaggedJetCorrectionsProducer",
        "producer:ValidTaggedJetsProducer",
        "producer:ValidBTaggedJetsProducer"))
    #if not (isData or isEmbedded): config["Processors"].append( "producer:MetCorrector")
    config["Processors"].extend(("producer:TauTauRestFrameSelector",
                                 "producer:DiLeptonQuantitiesProducer",
                                 "producer:DiJetQuantitiesProducer"))
    #if not isEmbedded:             config["Processors"].extend(("producer:SimpleEleTauFakeRateWeightProducer",
    #                                                            "producer:SimpleMuTauFakeRateWeightProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    #if isDY:                       config["Processors"].append( "producer:ZPtReweightProducer")
    #config["Processors"].append(                                "filter:MinimalPlotlevelFilter")
    if not isData:
        config["Processors"].append("producer:RooWorkspaceWeightProducer")
    if not isData:
        config["Processors"].append(
            "producer:TauTrigger2017EfficiencyProducer")
    #if not isEmbedded:             config["Processors"].append( "producer:JetToTauFakesProducer")
    config["Processors"].append("producer:EventWeightProducer")

    config["AddGenMatchedParticles"] = True
    config["AddGenMatchedTaus"] = True
    config["AddGenMatchedTauJets"] = True
    config["BranchGenMatchedElectrons"] = True
    config["BranchGenMatchedTaus"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer", "cutflow_histogram"]

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'et', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.syst_shifts_nom"
        ).build_config(nickname))
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)
    isHtt = re.search("HToTauTau", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsVetoElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauES",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_ee"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "EE"
    config["MinNElectrons"] = 2
    # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
    if re.search(
            "(Run2016|Embedding2016|Summer16|Embedding2017|Run2017|Spring17|Fall17)",
            nickname):
        config["HltPaths"] = [
            "HLT_Ele27_WPTight_Gsf", "HLT_Ele32_WPTight_Gsf",
            "HLT_Ele35_WPTight_Gsf"
        ]
    #config["ElectronLowerPtCuts"] = ["26.0"]
    config["ElectronLowerPtCuts"] = ["10.0"]
    config["ElectronUpperAbsEtaCuts"] = ["2.1"]
    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
    config["RooWorkspaceWeightNames"] = [
        "0:triggerWeight", "0:idweight", "0:isoweight", "0:trackWeight",
        "1:idweight", "1:isoweight", "1:trackWeight"
    ]
    config["RooWorkspaceObjectNames"] = [
        "0:e_trg_binned_ratio", "0:e_iso_binned_ratio", "0:e_id_ratio",
        "0:e_trk_ratio", "1:e_iso_binned_ratio", "1:e_id_ratio",
        "1:e_trk_ratio"
    ]
    config["RooWorkspaceObjectArguments"] = [
        "0:e_pt,e_eta,e_iso", "0:e_pt,e_eta,e_iso", "0:e_pt,e_eta",
        "0:e_pt,e_eta", "1:e_pt,e_eta,e_iso", "1:e_pt,e_eta", "1:e_pt,e_eta"
    ]
    config["EventWeight"] = "eventWeight"
    config["TauTauRestFrameReco"] = "collinear_approximation"
    if re.search(
            "(Run2016|Embedding2016|Summer16|Embedding2017|Run2017|Spring17|Fall17)",
            nickname):
        config["ElectronTriggerFilterNames"] = [
            "HLT_Ele27_WPTight_Gsf_v:hltEle27WPTightGsfTrackIsoFilter",
            "HLT_Ele32_WPTight_Gsf_v:hltEle32WPTightGsfTrackIsoFilter",
            "HLT_Ele35_WPTight_Gsf_v:hltEle35noerWPTightGsfTrackIsoFilter"
        ]

    config["InvalidateNonMatchingElectrons"] = True
    config["InvalidateNonMatchingMuons"] = False
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.TagAndProbe.Includes.TagAndProbeQuantitiesZee"
    ).build_list()

    config["Processors"] = [
        "producer:HltProducer", "producer:TagAndProbeElectronPairProducer",
        "filter:ValidElectronsFilter",
        "producer:ElectronTriggerMatchingProducer",
        "producer:EventWeightProducer"
    ]

    config["AddGenMatchedParticles"] = True
    config["AddGenMatchedTaus"] = True
    config["AddGenMatchedTauJets"] = True
    config["BranchGenMatchedElectrons"] = True
    config["BranchGenMatchedTaus"] = True
    config["Consumers"] = [
        "TagAndProbeElectronPairConsumer", "cutflow_histogram"
    ]
    #"CutFlowTreeConsumer",
    #"KappaElectronsConsumer",
    #"KappaTausConsumer",
    #"KappaTaggedJetsConsumer",
    #"RunTimeConsumer",
    #"PrintEventsConsumer"

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'ee', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.syst_shifts_nom"
        ).build_config(nickname))
Exemple #31
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)
    isHtt = re.search("HToTauTau", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsVetoMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.settingsTauES",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_mm"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "MM"
    config["MinNMuons"] = 2
    # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
    if re.search("(Run2016|Embedding2016|Summer16)", nickname):
        config["HltPaths"] = [
            "HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ",
            "HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ"
        ]

    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
    config["RooWorkspaceWeightNames"] = [
        "0:triggerWeight", "0:isoweight", "0:idweight", "0:trackWeight",
        "1:isoweight", "1:idweight", "1:trackWeight"
    ]
    config["RooWorkspaceObjectNames"] = [
        "0:m_trgOR4_binned_ratio", "0:m_iso_binned_ratio", "0:m_id_ratio",
        "0:m_trk_ratio", "1:m_iso_binned_ratio", "1:m_id_ratio",
        "1:m_trk_ratio"
    ]
    config["RooWorkspaceObjectArguments"] = [
        "0:m_pt,m_eta,m_iso", "0:m_pt,m_eta,m_iso", "0:m_pt,m_eta", "0:m_eta",
        "1:m_pt,m_eta,m_iso", "1:m_pt,m_eta", "1:m_eta"
    ]
    config["TauID"] = "TauIDRecommendation13TeV"
    config["TauUseOldDMs"] = True
    config["MuonLowerPtCuts"] = ["10.0"]
    config["MuonUpperAbsEtaCuts"] = ["2.5"]
    config["LowerZMassCut"] = 20.0
    config["ZMassRange"] = 13000.0
    config["VetoMultipleZs"] = False
    config["InvalidateNonZLeptons"] = True
    config["RequireOSZBoson"] = True
    config["DiTauPairMinDeltaRCut"] = 0.0
    config["DiTauPairIsTauIsoMVA"] = True
    config["DiTauPairHltPathsWithoutCommonMatchRequired"] = []
    config["DiTauPairHLTLast"] = True
    config["HLTBranchNames"] = [
        "trg_doublemuon:HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ",
        "trg_doublemuon:HLT_Mu17_TrkIsoVVL_TrkMu8_TrkIsoVVL_DZ"
    ]
    config["DiTauPairLepton1LowerPtCuts"] = [
        "HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v:19",
        "HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ_v:19"
    ]
    config["EventWeight"] = "eventWeight"
    config["TauTauRestFrameReco"] = "collinear_approximation"
    if re.search("(Run2016|Embedding2016|Summer16)", nickname):
        config["MuonTriggerFilterNames"] = [
            "HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v:hltDiMuonGlb17Glb8RelTrkIsoFiltered0p4DzFiltered0p2",
            "HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ_v:hltDiMuonGlb17Trk8RelTrkIsoFiltered0p4DzFiltered0p2"
        ]
    config["BTagWPs"] = ["medium"]
    config["InvalidateNonMatchingElectrons"] = False
    config["InvalidateNonMatchingMuons"] = True
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.syncQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.zptQuantities"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.Includes.lheWeights"
        ).build_list())
    config["Quantities"].extend(
        ["had_gen_match_pT_1", "had_gen_match_pT_2", "ZMass"])

    config["OSChargeLeptons"] = True
    config["TopPtReweightingStrategy"] = "Run1"
    config["MuonEnergyCorrection"] = "rochcorr2016"
    config[
        "MuonRochesterCorrectionsFile"] = "$CMSSW_BASE/src/Artus/KappaAnalysis/data/rochcorr2016"

    config["Processors"] = ["producer:MuonCorrectionsProducer"]
    config["Processors"] = [
        "producer:HltProducer", "producer:MetSelector",
        "producer:HttValidLooseElectronsProducer",
        "producer:HttValidLooseMuonsProducer", "producer:ValidMuonsProducer",
        "filter:ValidMuonsFilter", "producer:MuonTriggerMatchingProducer",
        "filter:MinMuonsCountFilter", "producer:ZmmProducer", "filter:ZFilter",
        "producer:HttValidVetoMuonsProducer", "producer:ValidElectronsProducer"
    ]
    if isDY or isWjets or isHtt:
        config["Processors"].append("producer:TauCorrectionsProducer")
    config["Processors"].extend(
        ("producer:ValidTausProducer", "producer:TauTriggerMatchingProducer",
         "producer:ValidMMPairCandidatesProducer",
         "filter:ValidDiTauPairCandidatesFilter",
         "producer:Run2DecayChannelProducer",
         "producer:DiVetoMuonVetoProducer",
         "producer:TaggedJetCorrectionsProducer",
         "producer:ValidTaggedJetsProducer",
         "producer:ValidBTaggedJetsProducer"))
    if isDY or isWjets or isHtt:
        config["Processors"].append("producer:MetCorrector")
    config["Processors"].extend(("producer:TauTauRestFrameSelector",
                                 "producer:DiLeptonQuantitiesProducer",
                                 "producer:DiJetQuantitiesProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    if isDY: config["Processors"].append("producer:ZPtReweightProducer")
    if not isData:
        config["Processors"].append("producer:RooWorkspaceWeightProducer")
    config["Processors"].append("producer:EventWeightProducer")

    config["AddGenMatchedParticles"] = True
    config["AddGenMatchedTaus"] = True
    config["AddGenMatchedTauJets"] = True
    config["BranchGenMatchedMuons"] = True
    config["BranchGenMatchedTaus"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer", "cutflow_histogram"]

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'mm', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2016_EmbeddingSelection.syst_shifts_nom"
        ).build_config(nickname))
Exemple #32
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_em"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "EM"
    config["MinNElectrons"] = 1
    config["MinNMuons"] = 1
    config["MaxNLooseElectrons"] = 1
    config["MaxNLooseMuons"] = 1
    # HltPaths_comment: The first path must be one with the higher pt cut on the electron. The second and last path must be one with the higher pt cut on the muon. Corresponding Pt cuts are implemented in the Run2DecayChannelProducer..
    if re.search("(Run2016|Embedding2016|Summer16)", nickname):
        config["HltPaths"] = [
            "HLT_IsoMu22", "HLT_IsoTkMu22", "HLT_IsoMu22_eta2p1",
            "HLT_IsoTkMu22_eta2p1", "HLT_VLooseIsoPFTau120_Trk50_eta2p1",
            "HLT_Ele25_eta2p1_WPTight_Gsf",
            "HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg",
            "HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ"
        ]
    config["ElectronLowerPtCuts"] = ["13.0"]
    config["ElectronUpperAbsEtaCuts"] = ["2.5"]
    config["MuonLowerPtCuts"] = ["10.0"]
    config["MuonUpperAbsEtaCuts"] = ["2.4"]
    config["DiTauPairMinDeltaRCut"] = 0.3
    config["DiTauPairIsTauIsoMVA"] = True
    config["DiTauPairLepton1LowerPtCuts"] = [
        "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:24.0",
        "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
    ]
    config["DiTauPairLepton2LowerPtCuts"] = [
        "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:24.0",
        "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
    ]
    config["DiTauPairNoHLT"] = False
    config["DiTauPairHLTLast"] = True
    config["HLTBranchNames"] = [
        "trg_singlemuon:HLT_IsoMu22_v", "trg_singlemuon:HLT_IsoTkMu22_v",
        "trg_singlemuon:HLT_IsoMu22_eta2p1_v",
        "trg_singlemuon:HLT_IsoTkMu22_eta2p1_v",
        "trg_singletau:HLT_VLooseIsoPFTau120_Trk50_eta2p1_v",
        "trg_singleelectron:HLT_Ele25_eta2p1_WPTight_Gsf_v",
        "trg_doubletau:HLT_DoubleMediumIsoPFTau35_Trk1_eta2p1_Reg_v",
        "trg_doubletau:HLT_DoubleMediumCombinedIsoPFTau35_Trk1_eta2p1_Reg_v",
        "trg_muonelectron:HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v",
        "trg_muonelectron:HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v",
        "trg_muonelectron:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v",
        "trg_muonelectron:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v"
    ]
    config["DiTauPairHltPathsWithoutCommonMatchRequired"] = [
        "HLT_IsoMu22_v", "HLT_IsoTkMu22_v", "HLT_IsoMu22_eta2p1_v",
        "HLT_IsoTkMu22_eta2p1_v", "HLT_VLooseIsoPFTau120_Trk50_eta2p1_v",
        "HLT_Ele25_eta2p1_WPTight_Gsf_v"
    ]

    if re.search("Summer16", nickname):
        config["TriggerEfficiencyData"] = [
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele12leg_eff.root",
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele23leg_eff.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu8leg_2016BtoH_eff.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu23leg_2016BtoH_eff.root"
        ]
        config["TriggerEfficiencyMc"] = [
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele12leg_eff.root",
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele23leg_eff.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu8leg_2016BtoH_eff.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu23leg_2016BtoH_eff.root"
        ]
        config["IdentificationEfficiencyData"] = [
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p15_eff.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
        ]
        config["IdentificationEfficiencyMc"] = [
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p15_eff.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
        ]
    elif re.search("Run2016", nickname):
        config["TriggerEfficiencyData"] = [
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root"
        ]
        config["TriggerEfficiencyMc"] = [
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
            "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root",
            "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_dummy.root"
        ]

    config["TriggerEfficiencyMode"] = "correlate_triggers"
    config["IdentificationEfficiencyMode"] = "multiply_weights"
    config["EventWeight"] = "eventWeight"
    config["TauTauRestFrameReco"] = "collinear_approximation"

    if re.search("(Run2016|Embedding2016|Summer16)", nickname):
        config["ElectronTriggerFilterNames"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter"
        ]
        config["MuonTriggerFilterNames"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8"
        ]

    config["BTagWPs"] = ["medium"]
    config["InvalidateNonMatchingElectrons"] = True
    config["InvalidateNonMatchingMuons"] = True
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.syncQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.MVAInputQuantities").build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.lheWeights"
        ).build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.zptQuantities"
        ).build_list())
    config["Quantities"].extend(["had_gen_match_pT_1", "had_gen_match_pT_2"])

    config["OSChargeLeptons"] = True
    config["TopPtReweightingStrategy"] = "Run1"

    config["Processors"] = [
        "producer:HttValidLooseElectronsProducer",
        "producer:HttValidLooseMuonsProducer",
        "producer:HltProducer",
        "producer:MetSelector",
        "producer:ValidElectronsProducer",
        "filter:ValidElectronsFilter",
        "producer:ElectronTriggerMatchingProducer",
        "filter:MinElectronsCountFilter",
        "producer:ValidMuonsProducer",
        "filter:ValidMuonsFilter",
        "producer:MuonTriggerMatchingProducer",
        "filter:MinMuonsCountFilter",
        "producer:ValidTausProducer",
        "producer:ValidEMPairCandidatesProducer",
        "filter:ValidDiTauPairCandidatesFilter",
        "producer:Run2DecayChannelProducer",  #"producer:MvaMetSelector",
        "producer:TaggedJetCorrectionsProducer",
        "producer:ValidTaggedJetsProducer",
        "producer:ValidBTaggedJetsProducer"
    ]
    if not (isData or isEmbedded):
        config["Processors"].append(
            "producer:MetCorrector")  #"producer:MvaMetCorrector"
    config["Processors"].extend(("producer:TauTauRestFrameSelector",
                                 "producer:DiLeptonQuantitiesProducer",
                                 "producer:DiJetQuantitiesProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    if isDY: config["Processors"].append("producer:ZPtReweightProducer")
    config["Processors"].append(
        "filter:MinimalPlotlevelFilter")  #"producer:MVATestMethodsProducer",
    #"producer:MVAInputQuantitiesProducer"))
    if not (isData or isEmbedded):
        config["Processors"].extend(("producer:TriggerWeightProducer",
                                     "producer:IdentificationWeightProducer"))
    if not isData:
        config["Processors"].append("producer:RooWorkspaceWeightProducer")
    config["Processors"].extend(
        ("producer:EmuQcdWeightProducer", "producer:EventWeightProducer"))

    config["AddGenMatchedParticles"] = True
    config["BranchGenMatchedElectrons"] = True
    config["BranchGenMatchedMuons"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer", "cutflow_histogram"]
    #"CutFlowTreeConsumer",
    #"KappaElectronsConsumer",
    #"KappaTausConsumer",
    #"KappaTaggedJetsConsumer",
    #"RunTimeConsumer",
    #"PrintEventsConsumer"

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'em', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.syst_shifts_nom"
        ).build_config(nickname))
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)
    isHtt = re.search("HToTauTau", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsVetoMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.Includes.settingsTauES",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_mm"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "MM"
    config["MinNMuons"] = 2
    # HltPaths_comment: The first path must be the single lepton trigger. A corresponding Pt cut is implemented in the Run2DecayChannelProducer.
    if re.search(
            "(Run2016|Embedding2016|Summer16|Embedding2017|Run2017|Spring17|Fall17)",
            nickname):
        config["HltPaths"] = [
            "HLT_IsoMu24",
            "HLT_IsoMu27",
        ]

    config[
        "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
    config["RooWorkspaceWeightNames"] = [
        "0:triggerWeight", "0:isoweight", "0:idweight", "0:trackWeight",
        "1:isoweight", "1:idweight", "1:trackWeight"
    ]
    config["RooWorkspaceObjectNames"] = [
        "0:m_trgOR4_binned_ratio", "0:m_iso_binned_ratio", "0:m_id_ratio",
        "0:m_trk_ratio", "1:m_iso_binned_ratio", "1:m_id_ratio",
        "1:m_trk_ratio"
    ]
    config["RooWorkspaceObjectArguments"] = [
        "0:m_pt,m_eta,m_iso", "0:m_pt,m_eta,m_iso", "0:m_pt,m_eta", "0:m_eta",
        "1:m_pt,m_eta,m_iso", "1:m_pt,m_eta", "1:m_eta"
    ]

    config["MuonIsoType"] = "none"
    config["MuonIso"] = "none"
    config["MuonDeltaBetaCorrectionFactor"] = 0.5
    config["MuonTrackDxyCut"] = 0.0
    config["MuonTrackDzCut"] = 0.0
    config["MuonLowerPtCuts"] = ["10.0"]
    config["MuonUpperAbsEtaCuts"] = ["2.4"]

    config["HLTBranchNames"] = [
        "trg_singlemuon_lowpt:HLT_IsoMu24_v",
        "trg_singlemuon:HLT_IsoMu27_v",
    ]

    config["EventWeight"] = "eventWeight"
    if re.search(
            "(Run2016|Embedding2016|Summer16|Embedding2017|Run2017|Spring17|Fall17)",
            nickname):
        config["MuonTriggerFilterNames"] = [
            "HLT_IsoMu24_v:hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07",
            "HLT_IsoMu27_v:hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07",
        ]
    config["BTagWPs"] = ["medium"]
    config["InvalidateNonMatchingElectrons"] = False
    config["InvalidateNonMatchingMuons"] = True
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.TagAndProbe.Includes.TagAndProbeQuantities"
    ).build_list()

    config["OSChargeLeptons"] = True
    config["TopPtReweightingStrategy"] = "Run1"

    config["Processors"] = [
        "producer:HltProducer", "producer:TagAndProbeMuonPairProducer",
        "filter:ValidMuonsFilter", "producer:MuonTriggerMatchingProducer",
        "producer:EventWeightProducer"
    ]

    config["Consumers"] = ["TagAndProbeMuonPairConsumer", "cutflow_histogram"]

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'mm', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM.syst_shifts_nom"
        ).build_config(nickname))
Exemple #34
0
	def merge_json(self,newfile):
		new = datasetsHelperTwopz(newfile)
		self.dataset.merge(new)
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("DY.?JetsToLLM(10to50|50|150)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)
    isSUSYggH = re.search("SUSYGluGluToHToTauTau", nickname)
    isSignal = re.search("HToTauTau", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsKappa",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.lheWeightAssignment",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsSampleStitchingWeights"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["SkipEvents"] = 0
    config["EventCount"] = -1
    config["Year"] = 2017
    config["InputIsData"] = isData

    if isSUSYggH:
        config["HiggsBosonMass"] = re.search(
            "SUSYGluGluToHToTauTauM(\d+)_",
            nickname).groups()[0]  #extracts generator mass from nickname
        config[
            "NLOweightsRooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/NLOWeights/higgs_pt_v2_mssm_mode.root"

    BosonPdgIds = {
        "DY.?JetsToLL|EWKZ2Jets|Embedding(2016|MC)": [23],
        "^(GluGlu|GluGluTo|VBF|Wminus|Wplus|Z)(HToTauTau|H2JetsToTauTau)":
        [25],
        "W.?JetsToLN|EWKW": [24],
        "SUSY(BB|GluGlu|GluGluTo)(BB)?HToTauTau": [25, 35, 36]
    }
    config["BosonPdgIds"] = [0]
    for key, pdgids in BosonPdgIds.items():
        if re.search(key, nickname): config["BosonPdgIds"] = pdgids

    config["BosonStatuses"] = [62]
    config["ChooseMvaMet"] = False
    config["DeltaRMatchingRecoElectronGenParticle"] = 0.2
    config["DeltaRMatchingRecoElectronGenTau"] = 0.2
    config["DeltaRMatchingRecoMuonGenParticle"] = 0.2
    config["DeltaRMatchingRecoMuonGenTau"] = 0.2
    config["DeltaRMatchingRecoTauGenParticle"] = 0.2
    config["DeltaRMatchingRecoTauGenTau"] = 0.2
    config["RecoElectronMatchingGenParticlePdgIds"] = [11, 13]
    config["RecoMuonMatchingGenParticlePdgIds"] = [11, 13]
    config["RecoTauMatchingGenParticlePdgIds"] = [11, 13]
    config["RecoElectronMatchingGenParticleMatchAllElectrons"] = "true"
    config["RecoMuonMatchingGenParticleMatchAllMuons"] = "true"
    config["RecoTauMatchingGenParticleMatchAllTaus"] = "true"
    config["MatchAllElectronsGenTau"] = "true"
    config["MatchAllMuonsGenTau"] = "true"
    config["MatchAllTausGenTau"] = "true"
    config["UpdateMetWithCorrectedLeptons"] = "true"

    config["MetFilter"] = [
        "Flag_HBHENoiseFilter", "Flag_HBHENoiseIsoFilter",
        "Flag_EcalDeadCellTriggerPrimitiveFilter", "Flag_goodVertices",
        "Flag_globalSuperTightHalo2016Filter", "Flag_BadPFMuonFilter",
        "Flag_BadChargedCandidateFilter"
    ]
    if isData:
        config["MetFilter"].extend(("Flag_eeBadScFilter", ))
    else:
        config["MetFilter"].extend(())

    config["OutputPath"] = "output.root"

    config["Processors"] = []
    #config["Processors"].append("filter:RunLumiEventFilter")
    if isData or isEmbedded: config["Processors"].append("filter:JsonFilter")
    if not isEmbedded: config["Processors"].append("filter:MetFilter")
    #if isDY or isTTbar:                  config["Processors"].append( "producer:ScaleVariationProducer")
    config["Processors"].append("producer:NicknameProducer")
    if not isData:
        config["Processors"].extend(
            ("producer:CrossSectionWeightProducer",
             "producer:NumberGeneratedEventsWeightProducer"))
        if not isEmbedded:
            config["Processors"].append("producer:PUWeightProducer")
        if isWjets or isDY or isSignal:
            config["Processors"].append(
                "producer:GenBosonFromGenParticlesProducer")
        if isDY or isEmbedded:
            config["Processors"].append(
                "producer:GenDiLeptonDecayModeProducer")
        config["Processors"].extend(("producer:GenParticleProducer",
                                     "producer:GenPartonCounterProducer"))
        if isSUSYggH:
            config["Processors"].append(
                "producer:NLOreweightingWeightsProducer")
        if isWjets or isDY or isEmbedded:
            config["Processors"].extend(
                ("producer:GenTauDecayProducer",
                 "producer:GenBosonDiLeptonDecayModeProducer"))
        config["Processors"].extend(
            ("producer:GeneratorWeightProducer",
             "producer:RecoMuonGenParticleMatchingProducer",
             "producer:RecoMuonGenTauMatchingProducer",
             "producer:RecoElectronGenParticleMatchingProducer",
             "producer:RecoElectronGenTauMatchingProducer",
             "producer:RecoTauGenParticleMatchingProducer",
             "producer:RecoTauGenTauMatchingProducer",
             "producer:MatchedLeptonsProducer"))
        #if isTTbar:                        config["Processors"].append( "producer:TTbarGenDecayModeProducer")

    if isData or isEmbedded: config["PileupWeightFile"] = "not needed"
    elif re.search(".*Fall17", nickname):
        config[
            "PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2017_294927-306462_13TeVFall17_17Nov2017ReReco_69p2mbMinBiasXS/%s.root" % nickname
    elif re.search(".*Summer17", nickname):
        config[
            "PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2017_294927-306462_13TeVSummer17_PromptReco_69p2mbMinBiasXS.root"
        #elif re.search(".*Summer17", nickname): config["PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2017_294927-306462_13TeVSummer17_PromptReco_80p0mbMinBiasXS.root"
    elif re.search(".*Summer16", nickname):
        config[
            "PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2016_271036-284044_13TeVMoriond17_23Sep2016ReReco_69p2mbMinBiasXS.root"
    else:
        config[
            "PileupWeightFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/pileup/Data_Pileup_2015_246908-260627_13TeVFall15MiniAODv2_PromptReco_69mbMinBiasXS.root"

    config[
        "ZptRooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_5.root"
    config["DoZptUncertainties"] = True
    config[
        "MetRecoilCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/TypeI-PFMet_Run2016BtoH.root"
    config[
        "MetShiftCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/PFMEtSys_2016.root"
    config[
        "MvaMetRecoilCorrectorFile"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/recoilMet/MvaMET_2016BCD.root"
    config["MetCorrectionMethod"] = "meanResolution"

    if isData or isEmbedded:
        if re.search("Run2017|Embedding2017", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt"
            ]
        elif re.search("Run2016|Embedding2016", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt"
            ]
        elif re.search("Run2015(C|D)|Embedding2015", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_13TeV_16Dec2015ReReco_Collisions15_25ns_JSON_v2.txt"
            ]
        elif re.search("Run2015B", nickname):
            config["JsonFiles"] = [
                "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/json/Cert_13TeV_16Dec2015ReReco_Collisions15_50ns_JSON_v2.txt"
            ]

    if re.search("Fall15MiniAODv2", nickname):
        config["SimpleMuTauFakeRateWeightLoose"] = [1.0, 1.0, 1.0, 1.0, 1.0]
        config["SimpleMuTauFakeRateWeightTight"] = [1.0, 1.0, 1.0, 1.0, 1.0]
        config["SimpleEleTauFakeRateWeightVLoose"] = [1.02, 1.11]
        config["SimpleEleTauFakeRateWeightTight"] = [1.80, 1.30]
    else:
        config["SimpleMuTauFakeRateWeightLoose"] = [
            1.22, 1.12, 1.26, 1.22, 2.39
        ]
        config["SimpleMuTauFakeRateWeightTight"] = [
            1.47, 1.55, 1.33, 1.72, 2.50
        ]
        config["SimpleEleTauFakeRateWeightVLoose"] = [1.21, 1.38]
        config["SimpleEleTauFakeRateWeightTight"] = [1.40, 1.90]

    # pipelines - channels including systematic shifts
    config["Pipelines"] = jsonTools.JsonDict()
    #config["Pipelines"] += importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.ee").build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.em"
    ).build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.et"
    ).build_config(nickname)
    #config["Pipelines"] += importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.mm").build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.mt"
    ).build_config(nickname)
    config["Pipelines"] += importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2MSSM2017.tt"
    ).build_config(nickname)

    return config
Exemple #36
0
def build_config(nickname):
    config = jsonTools.JsonDict()
    datasetsHelper = datasetsHelperTwopz.datasetsHelperTwopz(
        os.path.expandvars(
            "$CMSSW_BASE/src/Kappa/Skimming/data/datasets.json"))

    # define frequently used conditions
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    isData = datasetsHelper.isData(nickname) and (not isEmbedded)
    isTTbar = re.search("TT(To|_|Jets)", nickname)
    isDY = re.search("(DY.?JetsToLL|EWKZ2Jets)", nickname)
    isWjets = re.search("W.?JetsToLNu", nickname)

    ## fill config:
    # includes
    includes = [
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsLooseMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsElectronID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMuonID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsTauID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJEC",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsBTaggedJetID",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsMinimalPlotlevelFilter_em",
        #"HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsJECUncertaintySplit",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.settingsSvfit",
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.settingsMVATestMethods"
    ]
    for include_file in includes:
        analysis_config_module = importlib.import_module(include_file)
        config += analysis_config_module.build_config(nickname)

    # explicit configuration
    config["Channel"] = "EM"
    config["MinNElectrons"] = 1
    config["MinNMuons"] = 1
    # HltPaths_comment: The first path must be one with the higher pt cut on the electron. The second and last path must be one with the higher pt cut on the muon. Corresponding Pt cuts are implemented in the Run2DecayChannelProducer.
    if re.search("Run2016(B|C|D|E|F)|Summer16|Embedding", nickname):
        config["HltPaths"] = [
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL"
        ]
    elif re.search("Run2016(G|H)", nickname):
        config["HltPaths"] = [
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ"
        ]

    if re.search("Run2016(B|C|D|E|F)|Summer16|Embedding", nickname):
        config["HLTBranchNames"] = [
            "trg_electronmuon:HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v",
            "trg_electronmuon:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v"
        ]
    elif re.search("Run2016(G|H)", nickname):
        config["HLTBranchNames"] = [
            "trg_electronmuon:HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v",
            "trg_electronmuon:HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v"
        ]

    config["NoHltFiltering"] = False

    config["ElectronLowerPtCuts"] = ["13.0"]
    config["ElectronUpperAbsEtaCuts"] = ["2.5"]
    config["MuonLowerPtCuts"] = ["15.0"]
    config["MuonUpperAbsEtaCuts"] = ["2.4"]
    config["DeltaRTriggerMatchingElectrons"] = 0.4
    config["DeltaRTriggerMatchingMuons"] = 0.4
    config["DiTauPairMinDeltaRCut"] = 0.3
    config["DiTauPairIsTauIsoMVA"] = True

    if re.search("Run2016(G|H)", nickname):
        config["DiTauPairLepton1LowerPtCuts"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
        ]
        config["DiTauPairLepton2LowerPtCuts"] = [
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:24.0"
        ]
    elif isEmbedded:
        config["DiTauPairLepton1LowerPtCuts"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:-1.0",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:-1.0"
        ]
        config["DiTauPairLepton2LowerPtCuts"] = [
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:-1.0",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:-1.0"
        ]
    else:
        config["DiTauPairLepton1LowerPtCuts"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:24.0"
        ]
        config["DiTauPairLepton2LowerPtCuts"] = [
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:24.0"
        ]

    config["DiTauPairNoHLT"] = False
    config["EventWeight"] = "eventWeight"
    if isEmbedded:
        config[
            "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_7_embedded.root"
        config[
            "EmbeddedWeightWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_v16_7_embedded.root"
        config["EmbeddedWeightWorkspaceWeightNames"] = [
            "0:muonEffTrgWeight", "0:isoWeight", "0:idWeight",
            "0:triggerWeight", "1:isoWeight", "1:idWeight", "1:triggerWeight"
        ]
        config["EmbeddedWeightWorkspaceObjectNames"] = [
            "0:m_sel_trg_ratio", "0:e_iso_ratio", "0:e_id_ratio",
            "0:e_trg_ratio", "1:m_iso_ratio", "1:m_id_ratio", "1:m_trg_ratio"
        ]
        config["EmbeddedWeightWorkspaceObjectArguments"] = [
            "0:gt1_eta,gt2_eta", "0:e_pt,e_eta", "0:e_pt,e_eta",
            "0:e_pt,e_eta", "1:m_pt,m_eta", "1:m_pt,m_eta", "1:m_pt,m_eta"
        ]
    else:
        config[
            "RooWorkspace"] = "$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/scaleFactorWeights/htt_scalefactors_sm_moriond_v2.root"
        config["RooWorkspaceWeightNames"] = ["0:idIsoWeight", "1:idIsoWeight"]
        config["RooWorkspaceObjectNames"] = [
            "0:e_idiso0p15_desy_ratio", "1:m_idiso0p20_desy_ratio"
        ]
        config["RooWorkspaceObjectArguments"] = [
            "0:e_pt,e_eta", "1:m_pt,m_eta"
        ]
    config["TriggerEfficiencyData"] = [
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele12leg_eff.root",
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Electron_Ele23leg_eff.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu8leg_2016BtoH_eff.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_Run2016_Muon_Mu23leg_2016BtoH_eff.root"
    ]
    config["TriggerEfficiencyMc"] = [
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele12leg_eff.root",
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Electron_Ele23leg_eff.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu8leg_2016BtoH_eff.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/triggerWeights/triggerEfficiency_MC_Muon_Mu23leg_2016BtoH_eff.root"
    ]
    config["IdentificationEfficiencyData"] = [
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Electron_IdIso_IsoLt0p15_eff.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_Run2016_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
    ]
    config["IdentificationEfficiencyMc"] = [
        "0:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Electron_IdIso_IsoLt0p15_eff.root",
        "1:$CMSSW_BASE/src/HiggsAnalysis/KITHiggsToTauTau/data/root/identificationWeights/identificationEfficiency_MC_Muon_IdIso_IsoLt0p2_2016BtoH_eff.root"
    ]

    config["IdentificationEfficiencyMode"] = "multiply_weights"
    config["TauTauRestFrameReco"] = "collinear_approximation"
    config["TriggerEfficiencyMode"] = "correlate_triggers"

    if re.search("Run2016(G|H)", nickname):
        config["ElectronTriggerFilterNames"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLDZFilter",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLDZFilter"
        ]
        config["MuonTriggerFilterNames"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLDZFilter",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLDZFilter"
        ]
    else:
        config["ElectronTriggerFilterNames"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter"
        ]
        config["MuonTriggerFilterNames"] = [
            "HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v:hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23",
            "HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v:hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8"
        ]

    config["InvalidateNonMatchingElectrons"] = True
    config["InvalidateNonMatchingMuons"] = True
    config["InvalidateNonMatchingTaus"] = False
    config["InvalidateNonMatchingJets"] = False
    config["DirectIso"] = True

    config["Quantities"] = importlib.import_module(
        "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.fourVectorQuantities"
    ).build_list()
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.syncQuantities"
        ).build_list())

    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.svfitSyncQuantities"
        ).build_list())
    #config["Quantities"].extend(importlib.import_module("HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.Includes.splitJecUncertaintyQuantities").build_list())
    config["Quantities"].extend(
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Includes.weightQuantities"
        ).build_list())
    config["Quantities"].extend([
        "nLooseElectrons",
        "nLooseMuons",
        "nDiTauPairCandidates",
        "nAllDiTauPairCandidates",
        "trg_electronmuon",
        "pZetaMissVis",
        "lep1ErrD0",
        "lep1ErrDz",
        "lep2ErrD0",
        "lep2ErrDz",
        #~ "PVnDOF",
        "PVchi2"
    ])
    if isEmbedded:
        config["Quantities"].extend(["muonEffTrgWeight"])
    config["OSChargeLeptons"] = True

    config["Processors"] = [
        "producer:HltProducer", "filter:HltFilter", "producer:MetSelector"
    ]
    if not isData:
        config["Processors"].append("producer:ElectronCorrectionsProducer")
    config["Processors"].extend(
        ("producer:ValidElectronsProducer", "filter:ValidElectronsFilter",
         "producer:ElectronTriggerMatchingProducer",
         "filter:MinElectronsCountFilter", "producer:ValidMuonsProducer",
         "filter:ValidMuonsFilter", "producer:MuonTriggerMatchingProducer",
         "filter:MinMuonsCountFilter", "producer:ValidTausProducer",
         "producer:ValidEMPairCandidatesProducer",
         "filter:ValidDiTauPairCandidatesFilter",
         "producer:HttValidLooseElectronsProducer",
         "producer:HttValidLooseMuonsProducer",
         "producer:Run2DecayChannelProducer",
         "producer:TaggedJetCorrectionsProducer",
         "producer:ValidTaggedJetsProducer",
         "producer:ValidBTaggedJetsProducer"))
    #"producer:TaggedJetUncertaintyShiftProducer"))
    if not isData:
        config["Processors"].append(
            "producer:MetCorrector")  #"producer:MvaMetCorrector"
    config["Processors"].extend(("producer:TauTauRestFrameSelector",
                                 "producer:DiLeptonQuantitiesProducer",
                                 "producer:DiJetQuantitiesProducer"))
    if isTTbar:
        config["Processors"].append("producer:TopPtReweightingProducer")
    if isDY: config["Processors"].append("producer:ZPtReweightProducer")
    config["Processors"].append("filter:MinimalPlotlevelFilter")  #,
    #"producer:SvfitProducer")) #"producer:MVATestMethodsProducer"
    if isEmbedded:
        config["Processors"].append("producer:EmbeddedWeightProducer")
    if not (isData or isEmbedded):
        config["Processors"].append("producer:RooWorkspaceWeightProducer")
    if not isData:
        config["Processors"].extend(("producer:TriggerWeightProducer"))
    config["Processors"].append("producer:EventWeightProducer")

    config["AddGenMatchedParticles"] = True
    config["BranchGenMatchedElectrons"] = True
    config["BranchGenMatchedMuons"] = True
    config["Consumers"] = ["KappaLambdaNtupleConsumer",
                           "cutflow_histogram"]  #,
    #"SvfitCacheConsumer"]
    #"CutFlowTreeConsumer",
    #"KappaElectronsConsumer",
    #"KappaTausConsumer",
    #"KappaTaggedJetsConsumer",
    #"RunTimeConsumer",
    #"PrintEventsConsumer"

    # pipelines - systematic shifts
    return ACU.apply_uncertainty_shift_configs(
        'em', config,
        importlib.import_module(
            "HiggsAnalysis.KITHiggsToTauTau.data.ArtusConfigs.Run2Analysis.nominal"
        ).build_config(nickname))  # + \
Exemple #37
0
 def merge_json(self, newfile):
     new = datasetsHelperTwopz(newfile)
     self.dataset.merge(new)