def GetRareTopUnc(region):

    systematics = [
        Systematic("unc_ttv_xsec", configMgr.weights, 1.22, 0.78, "user",
                   "userOverallSys"),
        Systematic("unc_ttv_scales", configMgr.weights, 1.13, 0.87, "user",
                   "userOverallSys"),
    ]
    return systematics
def GetZjetsUnc():

    xsec_unc = [
        Systematic("unc_zjets_xsec", configMgr.weights, 1.05, 0.95, "user",
                   "userOverallSys")
    ]
    return xsec_unc
def getISRSyst(sig):
    errisr = getISRerr(sig)

    isrHighWeights = addWeight(configMgr.weights, str(1 + errisr))
    isrLowWeights = addWeight(configMgr.weights, str(1 - errisr))

    isrUnc = Systematic("ISR", configMgr.weights, isrHighWeights,
                        isrLowWeights, "weight", "overallSys")
    return isrUnc
def GetTopUnc(region):

    if "VRS" in region: region = "VRS"
    if "SRZ" in region: region = "SRZ"

    syst_dict = {
        "SRZ": [
            Systematic("unc_srz_top_theo_unc", configMgr.weights, 1.3, 0.7,
                       "user", "userOverallSys"),
        ],
        "VRS": [
            Systematic("unc_vrs_top_theo_unc", configMgr.weights, 1.29, 0.71,
                       "user", "userOverallSys"),
        ],
        "VRT": [
            Systematic("unc_vrt_top_theo_unc", configMgr.weights, 1.074, 0.926,
                       "user", "userOverallSys"),
        ],
    }
    systematics = syst_dict[region]
    return systematics
def GetSingeTopUnc(region):

    if "VRS" in region: region = "VRS"
    if "SRZ" in region: region = "SRZ"

    xsec_unc = [
        Systematic("unc_st_xsec", configMgr.weights, 1.053, 0.947, "user",
                   "userOverallSys")
    ]
    syst_dict = {
        "SRZ": [
            Systematic("unc_Wt_DS_unc", configMgr.weights, 1.63, 0.37, "user",
                       "userOverallSys"),
            Systematic("unc_Wt_rad_unc", configMgr.weights, 1.06, 0.94, "user",
                       "userOverallSys"),
        ],
        "CRT": [
            Systematic("unc_Wt_DS_unc", configMgr.weights, 1.73, 0.27, "user",
                       "userOverallSys"),
            Systematic("unc_Wt_rad_unc", configMgr.weights, 1.10, 0.90, "user",
                       "userOverallSys"),
        ],
        "VRS": [
            Systematic("unc_Wt_DS_unc", configMgr.weights, 1.34, 0.66, "user",
                       "userOverallSys"),
            Systematic("unc_Wt_rad_unc", configMgr.weights, 1.06, 0.94, "user",
                       "userOverallSys"),
        ],
        "VRT": [
            Systematic("unc_Wt_DS_unc", configMgr.weights, 1.53, 0.47, "user",
                       "userOverallSys"),
            Systematic("unc_Wt_rad_unc", configMgr.weights, 1.06, 0.94, "user",
                       "userOverallSys"),
        ],
    }
    systematics = syst_dict[region]
    systematics += xsec_unc
    return systematics
Exemple #6
0
    "CRTop"] = baselineSR[chn] + " && " + meffcut + " && " + bjetcut
configMgr.cutsDict["CRQCD"] = baselineSR[chn] + " && " + invdphicut[
    chn] + " && " + metomeffcut[chn] + " && " + meffcut
configMgr.cutsDict["CR1a"] = baselineSR[chn] + " && " + dphicut[
    chn] + " && " + metomeffcut[chn] + " && " + meffcut

# Tuples of nominal weights
configMgr.weights = ["genWeight", "pileupWeight", "normWeight"]

#--------------------------------------------------------------------------
# List of systematics
#--------------------------------------------------------------------------
configMgr.nomName = ""

#JES (tree-based)
jes = Systematic("JES", "", "_JESUP", "_JESDOWN", "tree",
                 "histoSys")  #"overallSys")

#JER (tree-based)a
jer = Systematic("JER", "", "_JER", "_JER", "tree", "histoSysOneSide")

#SCALEST (tree-based)
scalest = Systematic("SCALEST", "", "_SCALESTUP", "_SCALESTDOWN", "tree",
                     "overallSys")

#RESOST (tree-based)
resost = Systematic("RESOST", "", "_RESOSTUP", "_RESOSTDOWN", "tree",
                    "overallSys")

#PU
sysWeight_pileupUp = myreplace(configMgr.weights, ["pileupWeightUp"],
                               "pileupWeight")
#inputFileName = analysisname.rstrip()
#inputFileName = inputFileName.rstrip("NT")
#print "inputfilename = " + inputFileName

configMgr.inputFileNames = ["data/" + configMgr.analysisName + ".root"]
print "conf.inputFileNames = " + configMgr.inputFileNames[0]

## Suffix of nominal tree
configMgr.nomName = "_NoSys" #Actually not needed since I input directly histos

## Map regions to cut strings
configMgr.cutsDict["SREl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict["SRMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)

# The systematics
ttbargammaNorm  = Systematic("ttbargammaNorm",configMgr.weights, 1.40, 0.60, "user","userOverallSys")
WgammaNorm  = Systematic("WgammaNorm",configMgr.weights, 1.28, 0.72, "user","userOverallSys")
WjetsNormEl  = Systematic("WjetsNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
WjetsNormMu  = Systematic("WjetsNorm",configMgr.weights, 1.97, 0.03, "user","userOverallSys")
ZjetsNorm = Systematic("ZjetsNorm",configMgr.weights, 1.05, 0.95, "user","userOverallSys")
ZgammaNorm = Systematic("ZgammaNorm",configMgr.weights, 1.15, 0.85, "user","userOverallSys")
ttbarDilepNormEl = Systematic("ttbarDilepNorm",configMgr.weights, 1.136, 0.864, "user","userOverallSys")
ttbarDilepNormMu = Systematic("ttbarDilepNorm",configMgr.weights, 1.148, 0.852, "user","userOverallSys")
stNorm = Systematic("stNorm",configMgr.weights, 1.08, 0.92, "user","userOverallSys")
dibosonNorm = Systematic("dibosonNorm",configMgr.weights, 1.06, 0.94, "user","userOverallSys")
diphotonsNorm = Systematic("diphotonsNorm",configMgr.weights, 2.0, 0.5, "user","userOverallSys")
qcdElNorm = Systematic("qcdElNorm",configMgr.weights, 1.15, 0.85, "user","userOverallSys")

ttbarLepjetsNormEl = Systematic("ttbarLepjetsNorm",configMgr.weights, 4.0, 1.0-0.36, "user","userOverallSys")
ttbarLepjetsNormMu = Systematic("ttbarLepjetsNorm",configMgr.weights, 6.7, 1.0-0.33, "user","userOverallSys")
Exemple #8
0
gROOT.LoadMacro("./macros/AtlasStyle.C")
import ROOT
ROOT.SetAtlasStyle()

##########################

# Set observed and expected number of events in counting experiment
nDataCR   = [75.,35.] 	# Number of events observed in data in CR
nDataSR   = [90.,110.]	# Number of events observed in data in SR
nBkgCR    = [20.,20.]	# Number of predicted bkg events in CR
nBkgSR    = [20.,20.]	# Number of predicted bkg events in SR
nSigSR    = [10.,80.] 	# Number of predicted signal events N.B. signal only in SR
lumiError =  0.039 	# Relative luminosity uncertainty

# Define systematics (1 +/- relative uncertainties)
bg1xsec = Systematic("BG1Xsec",configMgr.weights,1.05,0.95,"user","userOverallSys")
sigxsec = Systematic("SigXsec",configMgr.weights,1.05,0.95,"user","userOverallSys")
xtrap = Systematic("BG2Xtrap",configMgr.weights,1.05,0.95,"user","userOverallSys")

##########################

# Setting the parameters of the hypothesis test
#configMgr.nTOYs=5000
configMgr.calculatorType=2 # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType=3   # 3=one-sided profile likelihood test statistic (LHC default)
configMgr.nPoints=20       # number of values scanned of signal-strength for upper-limit determination of signal strength.

##########################

# Give the analysis a name
configMgr.analysisName = "MyUserAnalysis_ShapeFactor"
Exemple #9
0
ktScaleTopHighWeights = ("genWeight", "eventWeight", "ktfacUpWeightTop",
                         "bTagWeight2Jet")
ktScaleTopLowWeights = ("genWeight", "eventWeight", "ktfacDownWeightTop",
                        "bTagWeight2Jet")

# QCD weights without and with b-jet selection
configMgr.weightsQCD = "qcdWeight"
configMgr.weightsQCDWithB = "qcdBWeight"

#--------------------
# List of systematics
#--------------------

# KtScale uncertainty as histoSys - two-sided, no additional normalization
topKtScale = Systematic("KtScaleTop", configMgr.weights, ktScaleTopHighWeights,
                        ktScaleTopLowWeights, "weight", "normHistoSys")
wzKtScale = Systematic("KtScaleWZ", configMgr.weights, ktScaleWHighWeights,
                       ktScaleWLowWeights, "weight", "normHistoSys")

# JES uncertainty as shapeSys - one systematic per region (combine WR and TR), merge samples
jes = Systematic("JES", "_NoSys", "_JESup", "_JESdown", "tree", "normHistoSys")
mcstat = Systematic("mcstat", "_NoSys", "_NoSys", "_NoSys", "tree",
                    "shapeStat")

# name of nominal histogram for systematics
configMgr.nomName = "_NoSys"

# List of samples and their plotting colours
topSample = Sample("Top", kGreen - 9)
topSample.setNormFactor("mu_Top", 1., 0., 5.)
topSample.setStatConfig(useStat)
Exemple #10
0
ktScaleWHighWeights = ("genWeight","eventWeight","ktfacUpWeightW","bTagWeight2Jet")
ktScaleWLowWeights = ("genWeight","eventWeight","ktfacDownWeightW","bTagWeight2Jet")

ktScaleTopHighWeights = ("genWeight","eventWeight","ktfacUpWeightTop","bTagWeight2Jet")
ktScaleTopLowWeights = ("genWeight","eventWeight","ktfacDownWeightTop","bTagWeight2Jet")
    
# QCD weights without and with b-jet selection
configMgr.weightsQCD = "qcdWeight"
configMgr.weightsQCDWithB = "qcdBWeight"

#--------------------
# List of systematics
#--------------------

# KtScale uncertainty as histoSys - two-sided, no additional normalization
topKtScale = Systematic("KtScaleTop",configMgr.weights,ktScaleTopHighWeights,ktScaleTopLowWeights,"weight","overallNormHistoSys")
wzKtScale = Systematic("KtScaleWZ",configMgr.weights,ktScaleWHighWeights,ktScaleWLowWeights,"weight","overallNormHistoSys")


# JES uncertainty as shapeSys - one systematic per region (combine WR and TR), merge samples
jes = Systematic("JES","_NoSys","_JESup","_JESdown","tree","overallNormHistoSys")

statWRwz  = Systematic("SLWR_wz", "_NoSys","","","tree","shapeStat")
statWRtop = Systematic("SLWR_top","_NoSys","","","tree","shapeStat")

# name of nominal histogram for systematics
configMgr.nomName = "_NoSys"

# List of samples and their plotting colours
topSample = Sample("Top",kGreen-9)
topSample.setNormFactor("mu_Top",1.,0.,5.)
Exemple #11
0
sample_bkg1.setStatConfig(True)
#
#sample_bkg2 = Sample("bkg2", ROOT.kMagenta)
#sample_bkg2.setStatConfig(True)

sample_data = Sample("data", ROOT.kBlack)
sample_data.setData()

#sample_sig = Sample("sig", ROOT.kRed)
#sample_sig.setStatConfig(True)

all_samples = [sample_bkg0, sample_bkg1,
               sample_data]  #, sample_bkg1, sample_bkg2, sample_data]

# systematics
syst_bkg0_cr = Systematic("SYST_BKG0_CR", configMgr.weights, 1.0 + 0.05,
                          1.0 - 0.05, "user", "userHistoSys")
syst_bkg0_sr = Systematic("SYST_BKG0_SR", configMgr.weights, 1.0 + 0.25,
                          1.0 - 0.25, "user", "userHistoSys")

syst_bkg1_cr = Systematic("SYST_BKG1_CR", configMgr.weights, 1.0 + 0.05,
                          1.0 - 0.05, "user", "userHistoSys")
syst_bkg1_sr = Systematic("SYST_BKG1_SR", configMgr.weights, 1.0 + 0.25,
                          1.0 - 0.25, "user", "userHistoSys")

sample_bkg0.addSystematic(syst_bkg0_cr)
sample_bkg1.addSystematic(syst_bkg1_cr)

#norm_syst_bkg1 = Systematic("Norm_Bkg1_0", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#norm_syst2_bkg1 = Systematic("Norm_Bkg1_1", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#norm_syst_bkg2 = Systematic("Norm_Bkg2", configMgr.weights, 1.0 + 0.10, 1.0 - 0.10, "user", "userHistoSys")
#sample_bkg1.addSystematic(norm_syst_bkg1)
Exemple #12
0
#configMgr.cutsDict["SRWMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict["WCRhHTEl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["WCRhHTMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict["WCRlHTEl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["WCRlHTMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict["HMEThHTEl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["HMEThHTMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["HMETmeffEl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["HMETmeffMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict["HMThHTEl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["HMThHTMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["HMTmeffEl"] = "1.0" #Only needed when doing directly the cuts (see tutorial)
#configMgr.cutsDict["HMTmeffMu"] = "1.0" #Only needed when doing directly the cuts (see tutorial)

# The systematics
ttbargammaNorm  = Systematic("ttbargammaNorm",configMgr.weights, 1.40, 0.60, "user","userOverallSys")
#WgammaNorm  = Systematic("WgammaNorm",configMgr.weights, 1.40, 0.60, "user","userOverallSys")
#WjetsNormEl  = Systematic("WjetsNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
#WjetsNormMu  = Systematic("WjetsNorm",configMgr.weights, 1.97, 0.03, "user","userOverallSys")
ZjetsNorm = Systematic("ZjetsNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
ZgammaNorm = Systematic("ZgammaNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
ttbarDilepNorm = Systematic("ttbarDilepNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
singletopNorm = Systematic("singletopNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
dibosonNorm = Systematic("dibosonNorm",configMgr.weights, 1.5, 0.5, "user","userOverallSys")
diphotonsNorm = Systematic("diphotonsNorm",configMgr.weights, 2.0, 0.5, "user","userOverallSys")
#qcdElNorm = Systematic("qcdElNorm",configMgr.weights, 1.15, 0.85, "user","userOverallSys")
#qcdMuNorm = Systematic("qcdMuNorm",configMgr.weights, 1.15, 0.85, "user","userOverallSys")

# extra theory for the SRs
#WgammaScaleSRS = Systematic("WgammaScaleSRS",configMgr.weights, 1.104, 1-.104, "user","userOverallSys") 
WgammaScaleSRW = Systematic("WgammaScaleSRW",configMgr.weights, 1.084, 1-.084, "user","userOverallSys") 
dwn = 0.7;
ucorb_up      = up;
ucorb_dwn     = dwn;
ucors_up      = 1.0;
ucors_dwn     = 1.0;
corb_up       = 1.0;
corb_dwn      = 1.0;
cors_up       = 1.0;
cors_dwn      = 1.0;
normFactorMin = 0.;
normFactorMax = 100.;

##########################

# Set uncorrelated systematics for bkg and signal (1 +- relative uncertainties)
ucb = Systematic("ucb", configMgr.weights, ucorb_up,ucorb_dwn, "user","userOverallSys")
ucs = Systematic("ucs", configMgr.weights, ucors_up,ucors_dwn, "user","userOverallSys")

# correlated systematic between background and signal (1 +- relative uncertainties)
corb = Systematic("cor",configMgr.weights, [corb_up],[corb_dwn], "user","userHistoSys")
cors = Systematic("cor",configMgr.weights, [cors_up],[cors_dwn], "user","userHistoSys")

##########################

# Setting the parameters of the hypothesis test
#configMgr.nTOYs=5000
configMgr.calculatorType=2 # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType=3   # 3=one-sided profile likelihood test statistic (LHC default)
configMgr.nPoints=20       # number of values scanned of signal-strength for upper-limit determination of signal strength.

##########################
sample_bkg0 = Sample("bkg0", ROOT.kBlue)
sample_bkg0.setStatConfig(True)

sample_bkg1 = Sample("bkg1", ROOT.kGreen)
sample_bkg1.setStatConfig(True)

sample_data = Sample("data", ROOT.kBlack)
sample_data.setData()

sample_sig = Sample("sig", ROOT.kRed)
sample_sig.setStatConfig(True)

all_samples = [sample_bkg0, sample_bkg1, sample_data]

# systematics
norm_syst_bkg0 = Systematic("Norm_Bkg0", configMgr.weights, 1.0 + 0.5, 1.0 - 0.5, "user", "userHistoSys")
sample_bkg0.addSystematic(norm_syst_bkg0)

cb1a = Systematic("Norm_Bkg1_A", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
cb1b = Systematic("Norm_Bkg1_B", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
cb1c = Systematic("Norm_Bkg1_C", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
cb1d = Systematic("Norm_Bkg1_D", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
sample_bkg1.addSystematic(cb1a)
sample_bkg1.addSystematic(cb1b)
#sample_bkg1.addSystematic(cb1c)
#sample_bkg1.addSystematic(cb1d)

def sample_by_name(name) :
    global all_samples
    for s in all_samples :
        if s.name.lower() == name.lower() :
def GetDibosonUnc(region, sample):

    # we use the same diboson uncertainties in VRS/SRZ and VRT/CRT
    if "VRT" in region: region = "CRT"
    if "VRS" in region or "SRZ" in region: region = "SRZ"

    xsec_unc = [
        Systematic("unc_db_xsec", configMgr.weights, 1.06, 0.94, "user",
                   "userOverallSys"),
    ]

    if 'llvv' in sample or 'WWoffZ' in sample:
        syst_dict = {
            "SRZ": [
                Systematic("unc_db_scales", configMgr.weights, 1.19, 0.81,
                           "user", "userOverallSys"),
                Systematic("unc_db_pdf", configMgr.weights, 1.034, 0.962,
                           "user", "userOverallSys"),
                Systematic("unc_db_gen", configMgr.weights, 1.71, 0.29, "user",
                           "userOverallSys"),
            ],
            "CRT": [
                Systematic("unc_db_scales", configMgr.weights, 1.24, 0.76,
                           "user", "userOverallSys"),
                Systematic("unc_db_pdf", configMgr.weights, 1.04, 0.979,
                           "user", "userOverallSys"),
                Systematic("unc_db_gen", configMgr.weights, 1.55, 0.45, "user",
                           "userOverallSys"),
            ],
        }

        systematics = syst_dict[region]
        systematics += xsec_unc

    elif 'WZZZ' in sample:
        syst_dict = {
            "SRZ": [
                Systematic("unc_db_gen", configMgr.weights, 1.38, 0.62, "user",
                           "userOverallSys"),
                Systematic("unc_db_scales", configMgr.weights, 1.23, 0.77,
                           "user", "userOverallSys"),
                Systematic("unc_db_pdf", configMgr.weights, 1.031, 0.971,
                           "user", "userOverallSys"),
            ],
            "CRT": [
                Systematic("unc_db_gen", configMgr.weights, 1.07, 0.93, "user",
                           "userOverallSys"),
                Systematic("unc_db_scales", configMgr.weights, 1.26, 0.74,
                           "user", "userOverallSys"),
                Systematic("unc_db_pdf", configMgr.weights, 1.04, 0.961,
                           "user", "userOverallSys"),
            ],
        }
        systematics = syst_dict[region]
        systematics += xsec_unc
    else:
        print "ERROR: GetDibosonUnc - unrecognised sample!"
    return systematics
#gROOT.LoadMacro("./macros/AtlasStyle.C")
import ROOT
#ROOT.SetAtlasStyle()

##########################

# Set observed and expected number of events in counting experiment
ndata = 7.  # Number of events observed in data
nbkg = 5.  # Number of predicted bkg events
nsig = 1.  # Number of predicted signal events
nbkgErr = 1.  # (Absolute) Statistical error on bkg estimate *from limited MC statistics*
nsigErr = 2.  # (Absolute) Statistical error on signal estimate *from limited MC statistics*
lumiError = 0.039  # Relative luminosity uncertainty

# Set uncorrelated systematics for bkg and signal (1 +- relative uncertainties)
ucb = Systematic("uncorrl_bkg", configMgr.weights, 1.2, 0.8, "user",
                 "userOverallSys")  # 20% error up and down

# correlated systematic between background and signal (1 +- relative uncertainties)

##########################

# Setting the parameters of the hypothesis test
configMgr.doExclusion = True  # True=exclusion, False=discovery
#configMgr.nTOYs=5000
configMgr.calculatorType = 2  # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType = 3  # 3=one-sided profile likelihood test statistic (LHC default)
configMgr.nPoints = 20  # number of values scanned of signal-strength for upper-limit determination of signal strength.

configMgr.writeXML = True

##########################
Exemple #17
0
configMgr.fixSigXSec=True  # fix SigXSec: 0, +/-1sigma 
configMgr.calculatorType=2 # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType=3   # 3=one-sided profile likelihood test statistic (LHC default)
configMgr.nPoints=20       # number of values scanned of signal-strength for upper-limit determination of signal strength.

## set scan range for the upper limit
#configMgr.scanRange = (0., 1.)

## Suffix of nominal tree
configMgr.nomName = "_NoSys"

## Map regions to cut strings
configMgr.cutsDict = {"SR":"1.0"}

## Systematics to be applied
jes = Systematic("JES","_NoSys","_JESup","_JESdown","tree","overallSys")
#jes = Systematic("JES",None,1.2,0.8,"user","overallSys")

## List of samples and their plotting colours
allbkgSample = Sample("Bkg",kGreen)
#allbkgSample.setNormFactor("mu_AllBkg",1.,0.,5.)
#allbkgSample.addSystematic(jesWT)
dataSample = Sample("Data",kBlack)
dataSample.setData()

commonSamples = [allbkgSample,dataSample]
configMgr.plotColours = [kGreen,kBlack]

## Parameters of the Measurement
measName = "BasicMeasurement"
measLumi = 1.
configMgr.fixSigXSec = True  # fix SigXSec: 0, +/-1sigma
configMgr.calculatorType = 2  # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType = 3  # 3=one-sided profile likelihood test statistic (LHC default)
configMgr.nPoints = 20  # number of values scanned of signal-strength for upper-limit determination of signal strength.

## Set the cache file
configMgr.histCacheFile = "data/" + configMgr.analysisName + ".root"

## Suffix of nominal tree
configMgr.nomName = "_NoSys"

## Map regions to cut strings
configMgr.cutsDict = {"SR": "1.0"}

## Systematics to be applied
jes = Systematic("JES", "_NoSys", "_JESup", "_JESdown", "tree", "overallSys")
#jes = Systematic("JES",None,1.2,0.8,"user","overallSys")

## List of samples and their plotting colours
allbkgSample = Sample("Bkg", kGreen)
#allbkgSample.setNormFactor("mu_AllBkg",1.,0.,5.)
#allbkgSample.addSystematic(jesWT)
dataSample = Sample("Data", kBlack)
dataSample.setData()

commonSamples = [allbkgSample, dataSample]
configMgr.plotColours = [kGreen, kBlack]

## Parameters of the Measurement
measName = "BasicMeasurement"
measLumi = 1.
configMgr.cutsDict["VRW3"]     = configMgr.cutsDict["VRW2"]+" && "+dphicut[chn]+" && "+metomeffcut[chn]
configMgr.cutsDict["VRT3"]     = configMgr.cutsDict["VRT2"]+" && "+dphicut[chn]+" && "+metomeffcut[chn]


# Tuples of nominal weights
configMgr.weights = ["genWeight","pileupWeight","normWeight"]


#--------------------------------------------------------------------------
# List of systematics
#--------------------------------------------------------------------------
configMgr.nomName = ""


# JES (tree-based)
jes = Systematic("JES","","_JESUP","_JESDOWN","tree","overallNormHistoSys") #"overallHistoSys") #"overallSys")

# JER (tree-based)a
jer = Systematic("JER","","_JER","_JER","tree","overallNormHistoSysOneSideSym") #"histoSysOneSide")

# SCALEST (tree-based)
scalest = Systematic("SCALEST","","_SCALESTUP","_SCALESTDOWN","tree","overallSys")

# RESOST (tree-based)
resost = Systematic("RESOST","","_RESOSTUP","_RESOSTDOWN","tree","overallSys")

# PU
sysWeight_pileupUp=myreplace(configMgr.weights,["pileupWeightUp"],"pileupWeight")
sysWeight_pileupDown=myreplace(configMgr.weights,["pileupWeightDown"],"pileupWeight")
pileup = Systematic("pileup",configMgr.weights,sysWeight_pileupUp,sysWeight_pileupDown,"weight","overallSys")
Exemple #20
0
## Suffix of nominal tree
configMgr.nomName = "_NoSys"  #Actually not needed since I input directly histos

## Map regions to cut strings
#configMgr.cutsDict = {"SR":"1.0"}
configMgr.cutsDict[
    "SREl"] = "1.0"  #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict[
    "SRMu"] = "1.0"  #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict[
    "WCREl"] = "1.0"  #Only needed when doing directly the cuts (see tutorial)
configMgr.cutsDict[
    "WCRMu"] = "1.0"  #Only needed when doing directly the cuts (see tutorial)

# The systematics
ttbargammaNorm = Systematic("ttbargammaNorm", configMgr.weights, 1.2, 0.8,
                            "user", "userOverallSys")
WgammaNorm = Systematic("WgammaNorm", configMgr.weights, 1.16, 0.84, "user",
                        "userOverallSys")
WjetsNorm = Systematic("WjetsNorm", configMgr.weights, 1.3, 0.7, "user",
                       "userOverallSys")
ZjetsNorm = Systematic("ZjetsNorm", configMgr.weights, 1.2, 0.8, "user",
                       "userOverallSys")
ZgammaNorm = Systematic("ZgammaNorm", configMgr.weights, 1.2, 0.8, "user",
                        "userOverallSys")
ttbarDilepNorm = Systematic("ttbarDilepNorm", configMgr.weights, 1.2, 0.8,
                            "user", "userOverallSys")
stNorm = Systematic("stNorm", configMgr.weights, 1.2, 0.8, "user",
                    "userOverallSys")
dibosonNorm = Systematic("dibosonNorm", configMgr.weights, 1.2, 0.8, "user",
                         "userOverallSys")
diphotonsNorm = Systematic("diphotonsNorm", configMgr.weights, 1.1, 0.9,
def formTreeSys(sysName, upSuffix, dnSuffix, sysType):
    #syntax: Systematics( sysName, nominalTreeSuffix, 1sigmaPpSuffix, 1sigmaDownSuffix, "tree"/"weight", sysType)
    return Systematic(sysName, "", "_" + sysName + upSuffix,
                      "_" + sysName + dnSuffix, "tree", sysType)
log.info("metomeff = %f" % metomeff)
log.info("dPhi = %f" % dPhi)
log.info("Full cutsDict can be printed with -L DEBUG")
log.debug(pprint.pformat(configMgr.cutsDict, width=60))

log.info("Wait 3 seconds for you to panic if these settings are wrong")
wait(3)
log.info("No panicking detected, continuing...")

#--------------------------------------------------------------------------
# List of systematics
#--------------------------------------------------------------------------
configMgr.nomName = ""

# JES (tree-based)
jes = Systematic("JES","","_JESUP","_JESDOWN","tree","overallNormHistoSys") 

# JER (tree-based)a
jer = Systematic("JER", "", "_JER", "_JER", "tree", "overallNormHistoSysOneSideSym") 

# SCALEST (tree-based)
scalest = Systematic("SCALEST", "", "_SCALESTUP", "_SCALESTDOWN", "tree", "overallSys")

# RESOST (tree-based)
resost = Systematic("RESOST", "", "_RESOST", "_RESOST", "tree", "overallNormHistoSysOneSideSym")

# PU
sysWeight_pileupUp=myreplace(configMgr.weights, ["pileupWeightUp"], "pileupWeight")
sysWeight_pileupDown=myreplace(configMgr.weights, ["pileupWeightDown"], "pileupWeight")
pileup = Systematic("pileup", configMgr.weights, sysWeight_pileupUp, sysWeight_pileupDown, "weight", "overallSys")
sample_bkg1 = Sample("bkg1", ROOT.kGreen)
sample_bkg1.setStatConfig(True)

sample_bkg2 = Sample("bkg2", ROOT.kMagenta)
sample_bkg2.setStatConfig(True)

sample_data = Sample("data", ROOT.kBlack)
sample_data.setData()

sample_sig = Sample("sig", ROOT.kRed)
sample_sig.setStatConfig(True)

all_samples = [sample_bkg0, sample_bkg1, sample_bkg2, sample_data]

# systematics
norm_syst_bkg1 = Systematic("Norm_Bkg1_0", configMgr.weights, 1.0 + 0.1,
                            1.0 - 0.1, "user", "userHistoSys")
norm_syst2_bkg1 = Systematic("Norm_Bkg1_1", configMgr.weights, 1.0 + 0.1,
                             1.0 - 0.1, "user", "userHistoSys")
norm_syst_bkg2 = Systematic("Norm_Bkg2", configMgr.weights, 1.0 + 0.10,
                            1.0 - 0.10, "user", "userHistoSys")
sample_bkg1.addSystematic(norm_syst_bkg1)
sample_bkg1.addSystematic(norm_syst2_bkg1)
sample_bkg2.addSystematic(norm_syst_bkg2)
#sample_bkg0.addSystematic(norm_syst_bkg0)

#cb1a = Systematic("Norm_Bkg1_A", configMgr.weights, 1.0 + 0.80, 1.0 - 0.80, "user", "userHistoSys")
#cb1b = Systematic("Norm_Bkg1_B", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#cb1c = Systematic("Norm_Bkg1_C", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#cb1d = Systematic("Norm_Bkg1_D", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#sample_bkg1.addSystematic(cb1a)
#sample_bkg1.addSystematic(cb1b)
#gROOT.LoadMacro("./macros/AtlasStyle.C")
import ROOT
#ROOT.SetAtlasStyle()

##########################

# Set observed and expected number of events in counting experiment
ndata = 7.  # Number of events observed in data
nbkg = 5.  # Number of predicted bkg events
nsig = 5.  # Number of predicted signal events
nbkgErr = 1.  # (Absolute) Statistical error on bkg estimate
nsigErr = 2.  # (Absolute) Statistical error on signal estimate
lumiError = 0.039  # Relative luminosity uncertainty

# Set uncorrelated systematics for bkg and signal (1 +- relative uncertainties)
ucb = Systematic("ucb", configMgr.weights, 1.2, 0.8, "user", "userOverallSys")
ucs = Systematic("ucs", configMgr.weights, 1.1, 0.9, "user", "userOverallSys")

# correlated systematic between background and signal (1 +- relative uncertainties)
corb = Systematic("cor", configMgr.weights, [1.1], [0.9], "user",
                  "userHistoSys")
cors = Systematic("cor", configMgr.weights, [1.15], [0.85], "user",
                  "userHistoSys")

##########################

# Setting the parameters of the hypothesis test
configMgr.doExclusion = True  # True=exclusion, False=discovery
#configMgr.nTOYs=5000
configMgr.calculatorType = 2  # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType = 3  # 3=one-sided profile likelihood test statistic (LHC default)
#sample_bkg1.setStatConfig(True)
#
#sample_bkg2 = Sample("bkg2", ROOT.kMagenta)
#sample_bkg2.setStatConfig(True)

sample_data = Sample("data", ROOT.kBlack)
sample_data.setData()

#sample_sig = Sample("sig", ROOT.kRed)
#sample_sig.setStatConfig(True)

all_samples = [sample_bkg0,
               sample_data]  #, sample_bkg1, sample_bkg2, sample_data]

# systematics
syst_bkg0_cr = Systematic("SYST_BKG_CR", configMgr.weights, 1.0 + 0.10,
                          1.0 - 0.10, "user", "userHistoSys")
syst_bkg0_sr = Systematic("SYST_BKG_SR", configMgr.weights, 1.0 + 0.05,
                          1.0 - 0.05, "user", "userHistoSys")
sample_bkg0.addSystematic(syst_bkg0_sr)

#norm_syst_bkg1 = Systematic("Norm_Bkg1_0", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#norm_syst2_bkg1 = Systematic("Norm_Bkg1_1", configMgr.weights, 1.0 + 0.1, 1.0 - 0.1, "user", "userHistoSys")
#norm_syst_bkg2 = Systematic("Norm_Bkg2", configMgr.weights, 1.0 + 0.10, 1.0 - 0.10, "user", "userHistoSys")
#sample_bkg1.addSystematic(norm_syst_bkg1)
#sample_bkg1.addSystematic(norm_syst2_bkg1)
#sample_bkg2.addSystematic(norm_syst_bkg2)


def sample_by_name(name):
    global all_samples
    for s in all_samples:
Exemple #26
0
def common_setting(mass):
    from configManager import configMgr
    from ROOT import kBlack, kGray, kRed, kPink, kViolet, kBlue, kAzure, kGreen, \
        kOrange
    from configWriter import Sample
    from systematic import Systematic
    import os

    color_dict = {
        "Zbb": kAzure,
        "Zbc": kAzure,
        "Zbl": kAzure,
        "Zcc": kAzure,
        "Zcl": kBlue,
        "Zl": kBlue,
        "Wbb": kGreen,
        "Wbc": kGreen,
        "Wbl": kGreen,
        "Wcc": kGreen,
        "Wcl": kGreen,
        "Wl": kGreen,
        "ttbar": kOrange,
        "stop": kOrange,
        "stopWt": kOrange,
        "ZZPw": kGray,
        "WZPw": kGray,
        "WWPw": kGray,
        "fakes": kPink,
        "Zjets": kAzure,
        "Wjets": kGreen,
        "top": kOrange,
        "diboson": kGray,
        "$Z\\tau\\tau$+HF": kAzure,
        "$Z\\tau\\tau$+LF": kBlue,
        "$W$+jets": kGreen,
        "$Zee$": kViolet,
        "Zhf": kAzure,
        "Zlf": kBlue,
        "Zee": kViolet,
        "others": kViolet,
        signal_prefix + "1000": kRed,
        signal_prefix + "1100": kRed,
        signal_prefix + "1200": kRed,
        signal_prefix + "1400": kRed,
        signal_prefix + "1600": kRed,
        signal_prefix + "1800": kRed,
        signal_prefix + "2000": kRed,
        signal_prefix + "2500": kRed,
        signal_prefix + "3000": kRed,
        # Add your new processes here
        "VH": kGray + 2,
        "VHtautau": kGray + 2,
        "ttH": kGray + 2,
    }

    ##########################

    # Setting the parameters of the hypothesis test
    configMgr.doExclusion = True  # True=exclusion, False=discovery
    configMgr.nTOYs = 10000  # default=5000
    configMgr.calculatorType = 0  # 2=asymptotic calculator, 0=frequentist calculator
    configMgr.testStatType = 3  # 3=one-sided profile likelihood test statistic (LHC default)
    configMgr.nPoints = 30  # number of values scanned of signal-strength for upper-limit determination of signal strength.
    configMgr.writeXML = False
    configMgr.seed = 40
    configMgr.toySeedSet = True
    configMgr.toySeed = 400

    # Pruning
    # - any overallSys systematic uncertainty if the difference of between the up variation and the nominal and between
    #   the down variation and the nominal is below a certain (user) given threshold
    # - for histoSys types, the situation is more complex:
    #   - a first check is done if the integral of the up histogram - the integral of the nominal histogram is smaller
    #     than the integral of the nominal histogram and the same for the down histogram
    #   - then a second check is done if the shape of the up, down and nominal histograms is very similar Only when both
    #     conditions are fulfilled the systematics will be removed.
    # default is False, so the pruning is normally not enabled
    configMgr.prun = True
    # The threshold to decide if an uncertainty is small or not is set by configMgr.prunThreshold = 0.005
    # where the number gives the fraction of deviation with respect to the nominal histogram below which an uncertainty
    # is considered to be small. The default is currently set to 0.01, corresponding to 1 % (This might be very aggressive
    # for the one or the other analyses!)
    configMgr.prunThreshold = 0.005
    # method 1: a chi2 test (this is still a bit experimental, so watch out if this is working or not)
    # method 2: checking for every bin of the histograms that the difference between up variation and nominal and down (default)
    configMgr.prunMethod = 2
    # variation and nominal is below a certain threshold.
    # Smoothing: HistFitter does not provide any smoothing tools.
    # More Details: https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/HistFitterAdvancedTutorial#Pruning_in_HistFitter

    ##########################

    # Keep SRs also in background fit confuguration
    configMgr.keepSignalRegionType = True
    configMgr.blindSR = BLIND

    # Give the analysis a name
    configMgr.analysisName = "bbtautau" + "X" + mass
    configMgr.histCacheFile = "data/" + configMgr.analysisName + ".root"
    configMgr.outputFileName = "results/" + configMgr.analysisName + "_Output.root"

    # Define cuts
    configMgr.cutsDict["SR"] = "1."

    # Define weights
    configMgr.weights = "1."

    # Define samples
    list_samples = []

    yields_mass = yields[mass]
    for process, yields_process in yields_mass.items():
        if process == 'data' or signal_prefix in process: continue
        # print("-> {} / Colour: {}".format(process, color_dict[process]))
        bkg = Sample(str(process), color_dict[process])
        bkg.setStatConfig(stat_config)
        # OLD: add lumi uncertainty (bkg/sig correlated, not for data-driven fakes)
        # NOW: add lumi by hand
        bkg.setNormByTheory(False)
        noms = yields_process["nEvents"]
        errors = yields_process["nEventsErr"] if use_mcstat else [0.0]
        # print("  nEvents (StatError): {} ({})".format(noms, errors))
        bkg.buildHisto(noms, "SR", my_disc, 0.5)
        bkg.buildStatErrors(errors, "SR", my_disc)
        if not stat_only and not no_syst:
            if process == 'fakes':
                key_here = "ATLAS_FF_1BTAG_SIDEBAND_Syst_hadhad"
                if not impact_check_continue(dict_syst_check, key_here):
                    bkg.addSystematic(
                        Systematic(key_here, configMgr.weights, 1.50, 0.50,
                                   "user", syst_type))
            else:
                key_here = "ATLAS_Lumi_Run2_hadhad"
                if not impact_check_continue(dict_syst_check, key_here):
                    bkg.addSystematic(
                        Systematic(key_here, configMgr.weights, 1.017, 0.983,
                                   "user", syst_type))
            for key, values in yields_process.items():
                if 'ATLAS' not in key: continue
                if impact_check_continue(dict_syst_check, key): continue
                # this should not be applied on the Sherpa
                if process == 'Zhf' and key == 'ATLAS_DiTauSF_ZMODEL_hadhad':
                    continue
                if process == 'Zlf' and key == 'ATLAS_DiTauSF_ZMODEL_hadhad':
                    continue
                ups = values[0]
                downs = values[1]
                systUpRatio = [
                    u / n if n != 0. else float(1.) for u, n in zip(ups, noms)
                ]
                systDoRatio = [
                    d / n if n != 0. else float(1.)
                    for d, n in zip(downs, noms)
                ]
                bkg.addSystematic(
                    Systematic(str(key), configMgr.weights, systUpRatio,
                               systDoRatio, "user", syst_type))
        list_samples.append(bkg)

    # FIXME: This is unusual!
    top = Sample('top', kOrange)
    top.setStatConfig(False)  # No stat error
    top.setNormByTheory(False)  # consider lumi for it
    top.buildHisto([0.00001], "SR", my_disc, 0.5)  # small enough
    # HistFitter can accept such large up ratio
    # Systematic(name, weight, ratio_up, ratio_down, syst_type, syst_fistfactory_type)
    if not stat_only and not no_syst:
        key_here = 'ATLAS_TTBAR_YIELD_UPPER_hadhad'
        if not impact_check_continue(dict_syst_check, key_here):
            top.addSystematic(
                Systematic(key_here, configMgr.weights, unc_ttbar[mass], 0.9,
                           "user", syst_type))
    list_samples.append(top)

    sigSample = Sample("Sig", kRed)
    sigSample.setNormFactor("mu_Sig", 1., 0., 100.)
    #sigSample.setStatConfig(stat_config)
    sigSample.setStatConfig(False)
    sigSample.setNormByTheory(False)
    noms = yields_mass[signal_prefix + mass]["nEvents"]
    errors = yields_mass[signal_prefix +
                         mass]["nEventsErr"] if use_mcstat else [0.0]
    sigSample.buildHisto([n * MY_SIGNAL_NORM * 1e-3 for n in noms], "SR",
                         my_disc, 0.5)
    #sigSample.buildStatErrors(errors, "SR", my_disc)
    for key, values in yields_mass[signal_prefix + mass].items():
        if 'ATLAS' not in key: continue
        if impact_check_continue(dict_syst_check, key):
            continue
        ups = values[0]
        downs = values[1]
        systUpRatio = [
            u / n if n != 0. else float(1.) for u, n in zip(ups, noms)
        ]
        systDoRatio = [
            d / n if n != 0. else float(1.) for d, n in zip(downs, noms)
        ]
        if not stat_only and not no_syst:
            sigSample.addSystematic(
                Systematic(str(key), configMgr.weights, systUpRatio,
                           systDoRatio, "user", syst_type))
    if not stat_only and not no_syst:
        key_here = "ATLAS_SigAccUnc_hadhad"
        if not impact_check_continue(dict_syst_check, key_here):
            sigSample.addSystematic(
                Systematic(key_here, configMgr.weights,
                           [1 + unc_sig_acc[mass] for i in range(my_nbins)],
                           [1 - unc_sig_acc[mass]
                            for i in range(my_nbins)], "user", syst_type))
        key_here = "ATLAS_Lumi_Run2_hadhad"
        if not impact_check_continue(dict_syst_check, key_here):
            sigSample.addSystematic(
                Systematic(key_here, configMgr.weights, 1.017, 0.983, "user",
                           syst_type))

    list_samples.append(sigSample)

    # Set observed and expected number of events in counting experiment
    n_SPlusB = yields_mass[signal_prefix +
                           mass]["nEvents"][0] + sum_of_bkg(yields_mass)[0]
    n_BOnly = sum_of_bkg(yields_mass)[0]
    if BLIND:
        # configMgr.useAsimovSet = True # Use the Asimov dataset
        # configMgr.generateAsimovDataForObserved = True # Generate Asimov data as obsData for UL
        # configMgr.useSignalInBlindedData = False
        ndata = sum_of_bkg(yields_mass)
    else:
        try:
            ndata = yields_mass["data"]["nEvents"]
        except:
            ndata = [0. for _ in range(my_nbins)]

    lumiError = 0.017  # Relative luminosity uncertainty

    dataSample = Sample("Data", kBlack)
    dataSample.setData()
    dataSample.buildHisto(ndata, "SR", my_disc, 0.5)
    list_samples.append(dataSample)

    # Define top-level
    ana = configMgr.addFitConfig("SPlusB")
    ana.addSamples(list_samples)
    ana.setSignalSample(sigSample)

    # Define measurement
    meas = ana.addMeasurement(name="NormalMeasurement",
                              lumi=1.0,
                              lumiErr=lumiError / 100000.)
    # make it very small so that pruned
    # we use the one added by hand
    meas.addPOI("mu_Sig")
    #meas.statErrorType = "Poisson"
    # Fix the luminosity in HistFactory to constant
    meas.addParamSetting("Lumi", True, 1)

    # Add the channel
    chan = ana.addChannel(my_disc, ["SR"], my_nbins, my_xmin, my_xmax)
    chan.blind = BLIND
    #chan.statErrorType = "Poisson"
    ana.addSignalChannels([chan])

    # These lines are needed for the user analysis to run
    # Make sure file is re-made when executing HistFactory
    if configMgr.executeHistFactory:
        if os.path.isfile("data/%s.root" % configMgr.analysisName):
            os.remove("data/%s.root" % configMgr.analysisName)
Exemple #27
0
# QCD weights without and with b-jet selection
# we turn the QCD background of for the tutorial as we do not want to use ATLAS data
#configMgr.weightsQCD = "qcdWeight"
#configMgr.weightsQCDWithB = "qcdBWeight"

#--------------------
# List of systematics
#--------------------

# Alpgen KtScale (weight-based)
ktScaleWHighWeights = ("genWeight", "eventWeight", "ktfacUpWeightW",
                       "bTagWeight2Jet")
ktScaleWLowWeights = ("genWeight", "eventWeight", "ktfacDownWeightW",
                      "bTagWeight2Jet")
wzKtScale = Systematic("KtScaleWZ", configMgr.weights, ktScaleWHighWeights,
                       ktScaleWLowWeights, "weight", "overallSys")

ktScaleTopHighWeights = ("genWeight", "eventWeight", "ktfacUpWeightTop",
                         "bTagWeight2Jet")
ktScaleTopLowWeights = ("genWeight", "eventWeight", "ktfacDownWeightTop",
                        "bTagWeight2Jet")
#topKtScale = Systematic("KtScaleTop",configMgr.weights,ktScaleTopHighWeights,ktScaleTopLowWeights,"weight","overallSys")
topKtScale = Systematic("KtScaleTop", configMgr.weights, ktScaleTopHighWeights,
                        ktScaleTopLowWeights, "weight", "histoSys")
#topKtScale = Systematic("KtScaleTop",configMgr.weights,ktScaleTopHighWeights,ktScaleTopLowWeights,"weight","normHistoSys")

#JES (tree-based)
jes = Systematic("JES", "_NoSys", "_JESup", "_JESdown", "tree", "overallSys")
configMgr.nomName = "_NoSys"

#-------------------------------------------
Exemple #28
0
    HistSys('JET_JER_EffectiveNP_4'),
    HistSys('JET_JER_EffectiveNP_5'),
    HistSys('JET_JER_EffectiveNP_6'),
    HistSys('JET_JER_EffectiveNP_7restTerm'),
    HistSys('JET_JvtEfficiency'),
    HistSys('JET_fJvtEfficiency'),
    HistSys('FT_EFF_B_systematics'),
    HistSys('FT_EFF_C_systematics'),
    HistSys('FT_EFF_Light_systematics'),
    HistSys('FT_EFF_extrapolation'),
    HistSys('FT_EFF_extrapolation_from_charm'),

    # met
    # Systematic('MET_SoftTrk_ResoPara', nom_name, '_MET_SoftTrk_ResoParaHigh', nom_name, 'tree', 'histoSysOneSide'),
    # Systematic('MET_SoftTrk_ResoPerp', nom_name, '_MET_SoftTrk_ResoPerpHigh', nom_name, 'tree', 'histoSysOneSide'),
    Systematic('MET_SoftTrk_Scale', nom_name, '_MET_SoftTrk_ScaleHigh',
               '_MET_SoftTrk_ScaleLow', 'tree', 'overallSys'),

    # pile-up
    HistSys('PRW_DATASF'),
]

# Flat 100% unc for photon+jet in SRs
sigma_gamjet_flat = 0.9999
syst_gamjet_flat_SR = Systematic("flat100GJ", 1, 1 + sigma_gamjet_flat,
                                 1 - sigma_gamjet_flat, "user",
                                 "userOverallSys")

# Fake photon backgrounds
## e->g
syst_feg = HistSys('EFAKE_SYST')
syst_stat_feg = Systematic('EFAKE_STAT', nom_name, nom_name, nom_name, 'tree',
print "Parsed user args %s" % str(args)

# Set observed and expected number of events in counting experiment
ndata = args.nobs  # Number of events observed in data
nbkg = args.nbkg  # Number of predicted bkg events
nsig = args.nsig  # Number of predicted signal events
nbkgErr = sqrt(
    nbkg
)  # (Absolute) Statistical error on bkg estimate *from limited MC statistics*
nsigErr = sqrt(
    nsig
)  # (Absolute) Statistical error on signal estimate *from limited MC statistics*
lumiError = 0.032  # Relative luminosity uncertainty

# Set uncorrelated systematics for bkg and signal (1 +- relative uncertainties)
ucb = Systematic("uncorrl_bkg", None, 1 + args.sigb, 1 - args.sigb, "user",
                 "userOverallSys")  # 30% error up and down

##########################

# Setting the parameters of the hypothesis test
if args.m3 != 0 and args.mu != 0:
    configMgr.doExclusion = True  # True=exclusion, False=discovery
else:
    configMgr.doExclusion = False  # True=exclusion, False=discovery

configMgr.nTOYs = args.ntoys
configMgr.calculatorType = 0  # 2=asymptotic calculator, 0=frequentist calculator
configMgr.testStatType = 3  # 3=one-sided profile likelihood test statistic (LHC default)
configMgr.nPoints = 1  # number of values scanned of signal-strength for upper-limit determination of signal strength.
configMgr.writeXML = True
Exemple #30
0
def HistSys(name='', kind='overallSys'):
    #return Systematic(name, nom_name, '_'+name+'Up', '_'+name+'Down', 'tree', kind)
    return Systematic(name, nom_name, '_' + name + 'High', '_' + name + 'Low',
                      'tree', kind)