def applyAnalysisCommandLineOptions(argv, config):
    if len(argv) < 3:
        return
    print "Applying command line options"
    if "1prong" in argv or "1pr" in argv:
        config.TauSelection.prongs = 1
    elif "2prong" in argv or "2pr" in argv:
        config.TauSelection.prongs = 2
    elif "3prong" in argv or "3pr" in argv:
        config.TauSelection.prongs = 3
    scaleFactors.assignTauTriggerSF(config.TauSelection, "nominal",config.Trigger.TautriggerEfficiencyJsonName)
def applyAnalysisCommandLineOptions(argv, config):
    if len(argv) < 3:
        return
    print "Applying command line options"
    if "1prong" in argv or "1pr" in argv:
        config.TauSelection.prongs = 1
    elif "2prong" in argv or "2pr" in argv:
        config.TauSelection.prongs = 2
    elif "3prong" in argv or "3pr" in argv:
        config.TauSelection.prongs = 3

    scaleFactors.assignTauTriggerSF(config.TauSelection, "nominal")
                prongs = 1,    # options: 1, 2, 3, 12, 13, 23, 123 or -1 (all)
                  rtau = 0.0,   # to disable set to 0.0
  againstElectronDiscr = "againstElectronTightMVA6",
#  againstElectronDiscr = "",
      againstMuonDiscr = "againstMuonLoose3",
#        isolationDiscr = "byMediumIsolationMVA3oldDMwLT",
        isolationDiscr = "byLooseCombinedIsolationDeltaBetaCorr3Hits",
)
# tau identification scale factors
scaleFactors.assignTauIdentificationSF(tauSelection)
# tau misidentification scale factors
scaleFactors.assignTauMisidentificationSF(tauSelection, "eToTau", "full", "nominal")
scaleFactors.assignTauMisidentificationSF(tauSelection, "muToTau", "full", "nominal")
scaleFactors.assignTauMisidentificationSF(tauSelection, "jetToTau", "full", "nominal")
# tau trigger SF
scaleFactors.assignTauTriggerSF(tauSelection, "nominal")

#====== Electron veto
eVeto = PSet(
         electronPtCut = 15.0,
        electronEtaCut = 2.5,
#            electronID = "mvaEleID_PHYS14_PU20bx25_nonTrig_V1_wp90", # highest (wp90) for vetoing (2012: wp95)
            electronID = "cutBasedElectronID_Spring15_25ns_V1_standalone_veto",
     electronIsolation = "veto", # loosest possible for vetoing ("veto"), "tight" for selecting
)

#====== Muon veto
muVeto = PSet(
             muonPtCut = 10.0,
            muonEtaCut = 2.5,
                muonID = "muIDLoose", # loosest option for vetoing (options: muIDLoose, muIDMedium, muIDTight)
Ejemplo n.º 4
0
    def __init__(self, selectorName, moduleName, config, verbose, **kwargs):
        self._selectorName = selectorName
        self._moduleName = moduleName
        self._config  = config.clone()
        self._verbose = verbose

        # Process all keyword arguments to make changes to the config
        keys = kwargs.keys()
        for key in keys:
	    value = kwargs[key]
	    if key == "systematics":
                self._config.histogramAmbientLevel = "Systematics"
          
                # Energy scales
		if value.startswith("TauES"):
		    self._config.TauSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up").replace("TauES","TES")
		elif value.startswith("JES"):
		    self._config.JetSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")
		elif value.startswith("JER"):
		    self._config.JetSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")
		elif value.startswith("UES"):
                    # FIXME: should also _y be taken into account?
		    self._config.METSelection.systematicVariation = "_"+value.replace("Plus_x","down_x").replace("Minus_x","up_x").replace("UES","MET_Type1_UnclusteredEn") 
		    self._config.METSelection.systematicVariation = "_"+value.replace("Plus_y","down_y").replace("Minus_y","up_y").replace("UES","MET_Type1_UnclusteredEn")
		# Fake tau 
		elif value.startswith("FakeTau"):
                    partonFakingTau = None
                    if "Electron" in value:
                        partonFakingTau = "eToTau"
                    elif "Muon" in value:
                        partonFakingTau = "muToTau"
                    elif "Jet" in value:
                        partonFakingTau = "jetToTau"
                    scaleFactors.assignTauMisidentificationSF(self._config.TauSelection, 
                                                              partonFakingTau, 
                                                              self._getDirectionString(value))
		# Trigger
		elif value.startswith("TauTrgEff"):
                    variationType = value.replace("TauTrgEff","").replace("Minus","").replace("Plus","")
                    scaleFactors.assignTauTriggerSF(self._config.TauSelection, self._getDirectionString(value), self._config.Trigger.TautriggerEfficiencyJsonName, variationType)
                elif value.startswith("METTrgEff"):
                    variationType = value.replace("METTrgEff","").replace("Minus","").replace("Plus","")
                    scaleFactors.assignMETTriggerSF(self._config.METSelection, self._config.BJetSelection.bjetDiscrWorkingPoint, self._getDirectionString(value), self._config.Trigger.METtriggerEfficiencyJsonName, variationType)

                # tau ID syst
                elif value.startswith("TauIDSyst"):
                    self._config.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")

		# b tag SF
		elif value.startswith("BTagSF") or value.startswith("BMistagSF"):
                    variationType = None
                    if value.startswith("BTagSF"):
                        variationType = "tag"
                    elif value.startswith("BMistagSF"):
                        variationType = "mistag"
                    direction = value.replace("BTagSF","").replace("BMistagSF","").replace("Minus","down").replace("Plus","up")
                    scaleFactors.updateBtagSFInformationForVariations(self._config.BJetSelection, direction=direction, variationInfo=variationType)

		# top quarks
		elif value.startswith("TopPt"):
                    self._config.topPtSystematicVariation = value.replace("TopPt","").replace("Plus","plus").replace("Minus","minus")
#		# PU weights
		elif value.startswith("PUWeight"):
                    self._config.PUWeightSystematicVariation = value.replace("PUWeight","").replace("Plus","plus").replace("Minus","minus")
		else:
		    if value != "nominal":
                        raise Exception("Error: unsupported variation item '%s'!"%value)
	    else:
		# Process optimization options
		# First check that key is found in config
		subkeys = key.split(".")
		subconfig = [self._config]
		suffix = ""
		for i in range(len(subkeys)-1):
		    if not hasattr(subconfig[len(subconfig)-1], subkeys[i]):
			raise Exception("Error: Cannot find key %s.%s in the config!"%(suffix, subkeys[i]))
		    subconfig.append(getattr(subconfig[len(subconfig)-1], subkeys[i]))
		    if suffix == "":
			suffix += "%s"%subkeys[i]
		    else:
			suffix += ".%s"%subkeys[i]
		# Set varied value in configuration (treat AngularCuts in a special way)
		if key.startswith("AngularCuts") and subkeys[len(subkeys)-1] == "workingPoint":
                    from HiggsAnalysis.NtupleAnalysis.parameters.signalAnalysisParameters import setAngularCutsWorkingPoint
                    setAngularCutsWorkingPoint(subconfig[len(subconfig)-1], value)
                else: # all other settings than AngularCuts
                    if not hasattr(subconfig[len(subconfig)-1], subkeys[len(subkeys)-1]):
                        raise Exception("Error: Cannot find key %s.%s in the config!"%(suffix, subkeys[len(subkeys)-1]))
                    setattr(subconfig[len(subconfig)-1], subkeys[len(subkeys)-1], value)
                # Additionally, set a new tau ID scale factor if needed
                    from HiggsAnalysis.NtupleAnalysis.parameters.scaleFactors import assignTauIdentificationSF
                    scaleFactors.assignTauIdentificationSF(subconfig[len(subconfig)-1])
                  rtau = 0.75,   # to disable set to 0.0
  againstElectronDiscr = "againstElectronTightMVA6",
#  againstElectronDiscr = "",
      againstMuonDiscr = "againstMuonLoose3",
        isolationDiscr = "byLooseIsolationMVArun2v1DBoldDMwLT", # MVA (default)
#        isolationDiscr = "byLooseCombinedIsolationDeltaBetaCorr3Hits",  # cut-based
)
# tau identification scale factors
scaleFactors.assignTauIdentificationSF(tauSelection)
# tau misidentification scale factors
scaleFactors.assignTauMisidentificationSF(tauSelection, "eToTau", "nominal")
scaleFactors.assignTauMisidentificationSF(tauSelection, "muToTau", "nominal")
scaleFactors.assignTauMisidentificationSF(tauSelection, "jetToTau", "nominal")
# tau trigger SF

scaleFactors.assignTauTriggerSF(tauSelection, "nominal", trg.TautriggerEfficiencyJsonName)

#====== Electron veto
eVeto = PSet(
    electronPtCut = 15.0,
    electronEtaCut = 2.5,
#            electronID = "mvaEleID_PHYS14_PU20bx25_nonTrig_V1_wp90", # highest (wp90) for vetoing (2012: wp95)
    electronID = "cutBasedElectronID_Spring15_25ns_V1_standalone_veto",
    electronIDType    = "MVA",  # options: "default", "MVA"
    electronMVA       = "ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values",
    electronMVACut    = "Loose",
    electronIsolation = "veto", # loosest possible for vetoing ("veto"), "tight" for selecting
    electronIsolType  = "mini", # options: "mini", "default"
)

#====== Muon veto
Ejemplo n.º 6
0
    def __init__(self, selectorName, moduleName, config, **kwargs):
        self._selectorName = selectorName
        self._moduleName = moduleName
        self._config = config.clone()
        #self.__dict__.update(kwargs)
	#print kwargs
        #===== Process all keyword arguments to make changes to the config
        keys = kwargs.keys()
        for key in keys:
	    value = kwargs[key]
	    if key == "systematics":
                self._config.histogramAmbientLevel = "Systematics"
                # Energy scales
		if value.startswith("tauES"):
		    self._config.TauSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up").replace("tauES","TES")
		elif value.startswith("JES"):
		    self._config.JetSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")
		# Fake tau 
		elif value.startswith("FakeTau"):
                    etaRegion = "full"
                    if "Barrel" in value:
                        etaRegion = "barrel"
                    elif "Endcap" in value:
                        etaRegion = "endcap"
                    partonFakingTau = None
                    if "Electron" in value:
                        partonFakingTau = "eToTau"
                    elif "Muon" in value:
                        partonFakingTau = "muToTau"
                    elif "Jet" in value:
                        partonFakingTau = "jetToTau"
                    scaleFactors.assignTauMisidentificationSF(self._config.TauSelection, 
                                                              partonFakingTau, etaRegion, 
                                                              self._getDirectionString(value))
		# Trigger
		elif value.startswith("TauTrgEff"):
                    variationType = value.replace("TauTrgEff","").replace("Minus","").replace("Plus","")
                    scaleFactors.assignTauTriggerSF(self._config.TauSelection, self._getDirectionString(value), variationType)
                elif value.startswith("METTrgEff"):
                    variationType = value.replace("METTrgEff","").replace("Minus","").replace("Plus","")
                    scaleFactors.assignMETTriggerSF(self._config.METSelection, self._config.BJetSelection.bjetDiscrWorkingPoint, self._getDirectionString(value), variationType)
		# b tag SF
		elif value.startswith("BTagSF") or value.startswith("BMistagSF"):
                    variationType = None
                    if value.startswith("BTagSF"):
                        variationType = "tag"
                    elif value.startswith("BMistagSF"):
                        variationType = "mistag"
                    direction = value.replace("BTagSF","").replace("BMistagSF","").replace("Minus","down").replace("Plus","up")
                    scaleFactors.setupBtagSFInformation(self._config.BJetSelection,
                                                        btagPayloadFilename="CSVv2.csv",
                                                        btagEfficiencyFilename="btageff_TTJets.json",
                                                        direction=direction,
                                                        variationInfo=variationType)
		# top quarks
		elif value.startswith("TopPt"):
                    self._config.topPtSystematicVariation = value.replace("TopPt","").replace("Plus","plus").replace("Minus","minus")
		else:
		    if value != "nominal":
                        raise Exception("Error: unsupported variation item '%s'!"%value)
	    else:
		# Process optimization options
		# First check that key is found in config
		subkeys = key.split(".")
		subconfig = [self._config]
		suffix = ""
		for i in range(len(subkeys)-1):
		    if not hasattr(subconfig[len(subconfig)-1], subkeys[i]):
			raise Exception("Error: Cannot find key %s.%s in the config!"%(suffix, subkeys[i]))
		    subconfig.append(getattr(subconfig[len(subconfig)-1], subkeys[i]))
		    if suffix == "":
			suffix += "%s"%subkeys[i]
		    else:
			suffix += ".%s"%subkeys[i]
		# Set value
		if key.startswith("AngularCuts") and subkeys[len(subkeys)-1] == "workingPoint":
                    from HiggsAnalysis.NtupleAnalysis.parameters.signalAnalysisParameters import setAngularCutsWorkingPoint
                    setAngularCutsWorkingPoint(subconfig[len(subconfig)-1], value)
                else:
                    if not hasattr(subconfig[len(subconfig)-1], subkeys[len(subkeys)-1]):
                        raise Exception("Error: Cannot find key %s.%s in the config!"%(suffix, subkeys[len(subkeys)-1]))
                    setattr(subconfig[len(subconfig)-1], subkeys[len(subkeys)-1], value)
    def __init__(self, selectorName, moduleName, config, verbose, **kwargs):
        self._selectorName = selectorName
        self._moduleName = moduleName
        self._config  = config.clone()
        self._verbose = verbose

        # Process all keyword arguments to make changes to the config
        keys = kwargs.keys()
        for key in keys:
	    value = kwargs[key]
	    if key == "systematics":
                self._config.histogramAmbientLevel = "Systematics"
          
                # Energy scales
		if value.startswith("TauES"):
		    self._config.TauSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up").replace("TauES","TES")
		elif value.startswith("JES"):
		    self._config.JetSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")
		elif value.startswith("JER"):
		    self._config.JetSelection.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")
		elif value.startswith("UES"):
                    # FIXME: should also _y be taken into account?
		    self._config.METSelection.systematicVariation = "_"+value.replace("Plus_x","down_x").replace("Minus_x","up_x").replace("UES","MET_Type1_UnclusteredEn") 
		    self._config.METSelection.systematicVariation = "_"+value.replace("Plus_y","down_y").replace("Minus_y","up_y").replace("UES","MET_Type1_UnclusteredEn")
		# Fake tau 
		elif value.startswith("FakeTau"):
                    partonFakingTau = None
                    if "Electron" in value:
                        partonFakingTau = "eToTau"
                    elif "Muon" in value:
                        partonFakingTau = "muToTau"
                    elif "Jet" in value:
                        partonFakingTau = "jetToTau"
                    scaleFactors.assignTauMisidentificationSF(self._config.TauSelection, 
                                                              partonFakingTau, 
                                                              self._getDirectionString(value))
		# Trigger
		elif value.startswith("TauTrgEff"):
                    variationType = value.replace("TauTrgEff","").replace("Minus","").replace("Plus","")
                    scaleFactors.assignTauTriggerSF(self._config.TauSelection, self._getDirectionString(value), self._config.Trigger.TautriggerEfficiencyJsonName, variationType)
                elif value.startswith("METTrgEff"):
                    variationType = value.replace("METTrgEff","").replace("Minus","").replace("Plus","")
                    scaleFactors.assignMETTriggerSF(self._config.METSelection, self._config.BJetSelection.bjetDiscrWorkingPoint, self._getDirectionString(value), self._config.Trigger.METtriggerEfficiencyJsonName, variationType)

                # tau ID syst
                elif value.startswith("TauIDSyst"):
                    self._config.systematicVariation = "_"+value.replace("Plus","down").replace("Minus","up")

		# b tag SF
		elif value.startswith("BTagSF") or value.startswith("BMistagSF"):
                    variationType = None
                    if value.startswith("BTagSF"):
                        variationType = "tag"
                    elif value.startswith("BMistagSF"):
                        variationType = "mistag"
                    direction = value.replace("BTagSF","").replace("BMistagSF","").replace("Minus","down").replace("Plus","up")
                    scaleFactors.updateBtagSFInformationForVariations(self._config.BJetSelection, direction=direction, variationInfo=variationType)

		# top-tag SF
		elif value.startswith("TopTagSF") or value.startswith("TopMistagSF"):
                    variationType = None
                    if value.startswith("TopTagSF"):
                        variationType = "tag"
                    elif value.startswith("TopMistagSF"):
                        variationType = "mistag"
                    direction = value.replace("TopTagSF","").replace("TopMistagSF","").replace("Minus","down").replace("Plus","up")
                    scaleFactors.updateTopTagSFInformationForVariations(self._config.TopSelectionBDT, direction=direction, variationInfo=variationType)

		# top quarks
		elif value.startswith("TopPt"):
                    self._config.topPtSystematicVariation = value.replace("TopPt","").replace("Plus","plus").replace("Minus","minus")
#		# PU weights
		elif value.startswith("PUWeight"):
                    self._config.PUWeightSystematicVariation = value.replace("PUWeight","").replace("Plus","plus").replace("Minus","minus")
		else:
		    if value != "nominal":
                        raise Exception("Error: unsupported variation item '%s'!"%value)
	    else:
		# Process optimization options
		# First check that key is found in config
		subkeys = key.split(".")
		subconfig = [self._config]
		suffix = ""
		for i in range(len(subkeys)-1):
		    if not hasattr(subconfig[len(subconfig)-1], subkeys[i]):
			raise Exception("Error: Cannot find key %s.%s in the config!"%(suffix, subkeys[i]))
		    subconfig.append(getattr(subconfig[len(subconfig)-1], subkeys[i]))
		    if suffix == "":
			suffix += "%s"%subkeys[i]
		    else:
			suffix += ".%s"%subkeys[i]
		# Set varied value in configuration (treat AngularCuts in a special way)
		if key.startswith("AngularCuts") and subkeys[len(subkeys)-1] == "workingPoint":
                    from HiggsAnalysis.NtupleAnalysis.parameters.signalAnalysisParameters import setAngularCutsWorkingPoint
                    setAngularCutsWorkingPoint(subconfig[len(subconfig)-1], value)
                else: # all other settings than AngularCuts
                    if not hasattr(subconfig[len(subconfig)-1], subkeys[len(subkeys)-1]):
                        raise Exception("Error: Cannot find key %s.%s in the config!"%(suffix, subkeys[len(subkeys)-1]))
                    setattr(subconfig[len(subconfig)-1], subkeys[len(subkeys)-1], value)
                # Additionally, set a new tau ID scale factor if needed
                    from HiggsAnalysis.NtupleAnalysis.parameters.scaleFactors import assignTauIdentificationSF
                    scaleFactors.assignTauIdentificationSF(subconfig[len(subconfig)-1])