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

# Give the analysis a name
configMgr.analysisName = "MyUserAnalysis"
configMgr.outputFileName = "results/%s_Output.root"%configMgr.analysisName

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

# Define weights
configMgr.weights = "1."

# Define samples
bkgSample = Sample("Bkg",kGreen-9)
bkgSample.setStatConfig(True)
bkgSample.buildHisto([nbkg],"UserRegion","cuts",0.5)
bkgSample.buildStatErrors([nbkgErr],"UserRegion","cuts")
bkgSample.addSystematic(corb)
bkgSample.addSystematic(ucb)

sigSample = Sample("Sig",kPink)
sigSample.setNormFactor("mu_Sig",1.,0.,100.)
sigSample.setStatConfig(True)
sigSample.setNormByTheory()
sigSample.buildHisto([nsig],"UserRegion","cuts",0.5)
sigSample.buildStatErrors([nsigErr],"UserRegion","cuts")
sigSample.addSystematic(cors)
sigSample.addSystematic(ucs)

dataSample = Sample("Data",kBlack)
Beispiel #2
0
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.)
topSample.setStatConfig(useStat)
topSample.setNormRegions([("SLWR","nJet"),("SLTR","nJet")])
wzSample = Sample("WZ",kAzure+1)
wzSample.setNormFactor("mu_WZ",1.,0.,5.)
wzSample.setStatConfig(useStat)
wzSample.setNormRegions([("SLWR","nJet"),("SLTR","nJet")])
bgSample = Sample("BG",kYellow-3)
bgSample.setNormFactor("mu_BG",1.,0.,5.)
bgSample.setStatConfig(useStat)
bgSample.setNormRegions([("SLWR","nJet"),("SLTR","nJet")])
qcdSample = Sample("QCD",kGray+1)
qcdSample.setQCD(True,"histoSys")
qcdSample.setStatConfig(useStat)
dataSample = Sample("Data",kBlack)
dataSample.setData()
#diboson
theoSysDiboson = Systematic("theoSysDiboson", configMgr.weights, 1.5,0.5, "user","userOverallSys")

#photon systematics in SR for Z
gammaToZSyst = Systematic("gammaToZSyst", configMgr.weights, 1.25,0.75, "user","userOverallSys")



#-------------------------------------------
# List of samples and their plotting colours
#-------------------------------------------
dibosonSample = Sample("Diboson",kRed+3)
dibosonSample.setTreeName("Diboson_SRAll")
dibosonSample.setFileList(dibosonFiles)
dibosonSample.setStatConfig(useStat)
dibosonSample.addSystematic(theoSysDiboson)

topSample = Sample("Top",kGreen-9)
topSample.setTreeName("Top_SRAll")
topSample.setNormFactor("mu_Top",1.,0.,50000.)
topSample.setFileList(topFiles)
topSample.setStatConfig(useStat)

qcdSample = Sample("MCMultijet",kOrange+2)
qcdSample.setTreeName("QCD_SRAll")
qcdSample.setNormFactor("mu_MCMultijet",1.,0.,500.)
qcdSample.setFileList(qcdFiles)
qcdSample.setStatConfig(useStat)

wSample = Sample("W",kAzure+1)
##########################

# Give the analysis a name
configMgr.analysisName = "MyUpperLimitAnalysis_SS"
configMgr.outputFileName = "results/%s_Output.root" % configMgr.analysisName

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

# Define weights
configMgr.weights = "1."

# Define samples
bkgSample = Sample("Bkg", kGreen - 9)
bkgSample.setStatConfig(True)
bkgSample.buildHisto([nbkg], "UserRegion", "cuts", 0.5)

bkgSample.addSystematic(ucb)

sigSample = Sample("Sig", kPink)
sigSample.setNormFactor("mu_SS", 1., 0., 10.)
#sigSample.setStatConfig(True)
sigSample.setNormByTheory()
sigSample.buildHisto([nsig], "UserRegion", "cuts", 0.5)

dataSample = Sample("Data", kBlack)
dataSample.setData()
dataSample.buildHisto([ndata], "UserRegion", "cuts", 0.5)

# Define top-level
if data_name == 'data15':
    efake_sample = Sample("efake15", color("efake"))
    jfake_sample = Sample("jfake15", color("jfake"))
elif data_name == 'data16':
    efake_sample = Sample("efake16", color("efake"))
    jfake_sample = Sample("jfake16", color("jfake"))
else: # should be 'data'
    efake_sample = Sample("efake", color("efake"))
    jfake_sample = Sample("jfake", color("jfake"))

# Data
data_sample = Sample(data_name, ROOT.kBlack)
data_sample.setData()

# stat uncertainty
wjets_sample.setStatConfig(useStat)
zjets_sample.setStatConfig(useStat)
wgamma_sample.setStatConfig(useStat)
zllgamma_sample.setStatConfig(useStat)
znunugamma_sample.setStatConfig(useStat)
ttbar_sample.setStatConfig(useStat)
ttbarg_sample.setStatConfig(useStat)
photonjet_sample.setStatConfig(useStat)
multijet_sample.setStatConfig(useStat)
diphoton_sample.setStatConfig(useStat)
vgammagamma_sample.setStatConfig(useStat)
vqqgamma_sample.setStatConfig(useStat)

if use_mc_bkgs:
    bkg_samples = [
        wgamma_sample, 
##########################

# Give the analysis a name
configMgr.analysisName = "MyUserAnalysis"
configMgr.outputFileName = "results/%s_Output.root" % configMgr.analysisName

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

# Define weights
configMgr.weights = "1."

# Define samples
bkgSample = Sample("Bkg", kGreen - 9)
bkgSample.setStatConfig(False)
bkgSample.buildHisto([nbkg], "UserRegion", "cuts")
# bkgSample.buildStatErrors([nbkgErr],"UserRegion","cuts")
# bkgSample.addSystematic(corb)
bkgSample.addSystematic(ucb)

sigSample = Sample("Sig", kPink)
sigSample.setNormFactor("mu_Sig", 1.0, 0.0, 100.0)
sigSample.setStatConfig(False)
sigSample.setNormByTheory(False)
sigSample.buildHisto([nsig], "UserRegion", "cuts")
# sigSample.buildStatErrors([nsigErr],"UserRegion","cuts")
# sigSample.addSystematic(cors)
# sigSample.addSystematic(ucs)

dataSample = Sample("Data", kBlack)
    ##########################

    # Give the analysis a name
    configMgr.analysisName = "SimpleUL_%s" % SR
    configMgr.outputFileName = "results/%s_Output.root" % configMgr.analysisName

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

    # Define weights
    configMgr.weights = "1."

    # Define samples
    bkgSample = Sample("Bkg", kGreen - 9)
    bkgSample.setStatConfig(False)
    bkgSample.buildHisto([nbkg], "UserRegion", "cuts")
    #bkgSample.buildStatErrors([nbkgErr],"UserRegion","cuts")
    #bkgSample.addSystematic(corb)
    bkgSample.addSystematic(ucb)

    dataSample = Sample("Data", kBlack)
    dataSample.setData()
    dataSample.buildHisto([ndata], "UserRegion", "cuts")

    # Define top-level
    ana = configMgr.addFitConfig("SPlusB")
    ana.addSamples([bkgSample, dataSample])
    #ana.setSignalSample(sigSample)

    # Define measurement
# QCD
theoSysQCD = Systematic("theoSysQCD", configMgr.weights, 1.0 + theoSysQCDNumber,1.0-theoSysQCDNumber, "user", "userOverallSys")
QCDGausSys = Systematic("QCDGausSys", "", "_ghi", "_glo", "tree", "overallNormHistoSys")
QCDTailSys = Systematic("QCDTailSys", "", "_thi", "_tlo", "tree", "overallNormHistoSys")

# Diboson
theoSysDiboson = Systematic("theoSysDiboson",  configMgr.weights,  1.5, 0.5,  "user", "userOverallSys")

#-------------------------------------------
# List of samples and their plotting colours
#-------------------------------------------
# Diboson
dibosonSample = Sample("Diboson", kRed+3)
dibosonSample.setTreeName("Diboson_SRAll")
dibosonSample.setFileList(dibosonFiles)
dibosonSample.setStatConfig(useStat)

# Top
topSample = Sample("ttbar", kGreen-9)
topSample.setTreeName("Top_SRAll")
topSample.setNormFactor("mu_Top", 1., 0., 500.)
topSample.setFileList(topFiles)
topSample.setStatConfig(useStat) 

if useTheoSys:
    topSample.addSystematic(theoSysTop)

if useSyst :
    topSample.addSystematic(pileup)
    topSample.addSystematic(jes)
    topSample.addSystematic(jer)
                        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)
topSample.setNormRegions([("SLWR", "nJet"), ("SLTR", "nJet")])
wzSample = Sample("WZ", kAzure + 1)
wzSample.setNormFactor("mu_WZ", 1., 0., 5.)
wzSample.setStatConfig(useStat)
wzSample.setNormRegions([("SLWR", "nJet"), ("SLTR", "nJet")])
bgSample = Sample("BG", kYellow - 3)
bgSample.setNormFactor("mu_BG", 1., 0., 5.)
bgSample.setStatConfig(useStat)
bgSample.setNormRegions([("SLWR", "nJet"), ("SLTR", "nJet")])
qcdSample = Sample("QCD", kGray + 1)
qcdSample.setQCD(True, "histoSys")
qcdSample.setStatConfig(useStat)
dataSample = Sample("Data", kBlack)
dataSample.setData()
dataSample.buildHisto([86., 66., 62., 35., 11., 7., 2., 0.], "SLTR", "nJet", 2)
Beispiel #10
0
phoScaleElst = Systematic("phoScale",configMgr.weights, 1.036, 1-.036, "user","userOverallSys")
phoScaleEldiboson = Systematic("phoScale",configMgr.weights, 1.029, 1-.029, "user","userOverallSys")
phoScaleElZgamma = Systematic("phoScale",configMgr.weights, 1.025, 1-.025, "user","userOverallSys")

# phoScaleMuWgamma = Systematic("phoScale",configMgr.weights, 1.018, 1-.018, "user","userOverallSys")
# phoScaleMuttgamma = Systematic("phoScale",configMgr.weights, 1.015,1-.015, "user","userOverallSys")
# phoScaleMuttbarDilep = Systematic("phoScale",configMgr.weights, 1.028, 1-.028, "user","userOverallSys")
# phoScaleMust = Systematic("phoScale",configMgr.weights, 1.023, 1-.023, "user","userOverallSys")
# phoScaleMudiboson = Systematic("phoScale",configMgr.weights, 1.040, 1-.040, "user","userOverallSys")
# phoScaleMuZgamma = Systematic("phoScale",configMgr.weights, 1.025, 1-.025, "user","userOverallSys")

## List of samples and their plotting colours. Associate dedicated systematics if applicable.

ttbargamma = Sample("ttbargamma",46) # brick
ttbargamma.setNormByTheory()
ttbargamma.setStatConfig(True)
ttbargamma.addSystematic(ttbargammaNorm)

Wgamma = Sample("Wgamma",7) # cyan
Wgamma.setNormFactor("mu_Wgamma",1.,0.,5.)
Wgamma.setNormRegions([("WCRhHTEl", "cuts")])
Wgamma.setStatConfig(True)
#Wgamma.addSystematic(WgammaNorm)

Zgamma = Sample("Zgamma",kViolet) # cyan
Zgamma.setNormByTheory()
Zgamma.setStatConfig(True)
Zgamma.addSystematic(ZgammaNorm)

Zjets = Sample("Zjets",kBlue) # cyan
Zjets.setNormByTheory()
Beispiel #11
0
photon = Systematic("photon", configMgr.weights, 1.05, 0.95, "user",
                    "userOverallSys")
electron = Systematic("electron", configMgr.weights, 1.05, 0.95, "user",
                      "userOverallSys")
muon = Systematic("muon", configMgr.weights, 1.05, 0.95, "user",
                  "userOverallSys")
metMu = Systematic("metMu", configMgr.weights, 1.1, 0.9, "user",
                   "userOverallSys")
metEl = Systematic("metEl", configMgr.weights, 1.1, 0.9, "user",
                   "userOverallSys")

## List of samples and their plotting colours. Associate dedicated systematics if applicable.

ttbargamma = Sample("ttbargamma", 46)  # brick
ttbargamma.setNormByTheory()
ttbargamma.setStatConfig(True)
ttbargamma.addSystematic(ttbargammaNorm)

Wgamma = Sample("Wgamma", 7)  # cyan
Wgamma.setNormByTheory()
Wgamma.setStatConfig(True)
Wgamma.addSystematic(WgammaNorm)

Zgamma = Sample("Zgamma", 7)  # cyan
Zgamma.setNormByTheory()
Zgamma.setStatConfig(True)
Zgamma.addSystematic(ZgammaNorm)

Zleplep = Sample("Zleplep", 7)  # cyan
Zleplep.setNormByTheory()
Zleplep.setStatConfig(True)
Beispiel #12
0
## Setting up Samples and normalization factors
################################################################################################
userPrint("Setting up samples, norm factors and systematics")

# Specify the top level XML and the paramater of interest
tlx = configMgr.addFitConfig("TopLvlXML")
meas = tlx.addMeasurement(name="NormalMeasurement", lumi=1.0, lumiErr=0.028)  # fractional luminosity error
meas.addPOI("mu_SIG")  ## EXCL:mu_SIG, upper limit table

# Determine if we should use stat
useStat = False  # This is added as systematics below

# Add systematics here

# Stat
zjetsSample.setStatConfig(useStat)
fakeSample.setStatConfig(useStat)
higgsSample.setStatConfig(useStat)
wwSample.setStatConfig(useStat)
wzSample.setStatConfig(useStat)
zzSample.setStatConfig(useStat)
tribosonSample.setStatConfig(useStat)
ttbarVSample.setStatConfig(useStat)

if not useStat:
    zjetsSample.addSystematic(sysObj.AR_mcstat_Zjets)
    fakeSample.addSystematic(sysObj.AR_mcstat_fake)
    higgsSample.addSystematic(sysObj.AR_mcstat_Higgs)
    wwSample.addSystematic(sysObj.AR_mcstat_WW)
    wzSample.addSystematic(sysObj.AR_mcstat_WZ)
    zzSample.addSystematic(sysObj.AR_mcstat_ZZ)
##########################

# Give the analysis a name
configMgr.analysisName = "MyUserAnalysis"
configMgr.outputFileName = "results/%s_Output.root"%configMgr.analysisName

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

# Define weights
configMgr.weights = "1."

# Define samples
bkgSample = Sample("Bkg",kGreen-9)
bkgSample.setStatConfig(True)
bkgSample.buildHisto([nbkg],"UserRegion","cuts")
bkgSample.buildStatErrors([nbkgErr],"UserRegion","cuts") ###
if(runMode=="exclusion"):
	bkgSample.addSystematic(corb)
bkgSample.addSystematic(ucb)

sigSample = Sample("Sig",kPink)
sigSample.setNormFactor("mu_Sig",1.,normFactorMin,normFactorMax)
sigSample.setStatConfig(False)
sigSample.setNormByTheory(False)
sigSample.buildHisto([nsig],"UserRegion","cuts")
sigSample.buildStatErrors([nsigErr],"UserRegion","cuts") ###
sigSample.addSystematic(cors) ###
sigSample.addSystematic(ucs) ###
configMgr.weights = ["1"]

configMgr.calculatorType = 2 # calculator type: 0= Frequentist, 1=Hybrid, 2=Aymptotic
configMgr.testStatType = 3 # # test stat type: 0=LEP, 1=Tevatron, 2=Profile Likelihood, 3=One-sided PLL
configMgr.nPoints = 20
configMgr.writeXML = True

configMgr.histCacheFile = "data/" + configMgr.analysisName + ".root"
configMgr.outputFileName = "results/" + configMgr.analysisName + "_Output.root"


print "is discovery ? %s" % (myFitType == FitType.Discovery)

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)
Beispiel #15
0
useStat = True
if userOpts.splitMCSys :
    useStat = False

# If using stat set some limits
tlx.statErrThreshold = 0.001

# define quantities to make configuration below easier
SR      = userOpts.signalRegion
lepChan = userOpts.leptonChannel

if userOpts.do2L :
    # ----------------------------------------------------- #
    #                        Zjets                          # 
    # ----------------------------------------------------- #
    zjetsSample.setStatConfig(useStat)
    if userOpts.splitMCSys :
        zjetsSample.addSystematic(sysObj.AR_mcstat_ZX)
    zjetsSample.setNormByTheory()
    zjetsSample = addSys(zjetsSample, False, sysObj)
    
    # ----------------------------------------------------- #
    #                        Higgs                          # 
    # ----------------------------------------------------- #
    higgsSample.setStatConfig(useStat)
    if userOpts.splitMCSys :
        higgsSample.addSystematic(sysObj.AR_mcstat_H)
    higgsSample.setNormByTheory()
    higgsSample = addSys(higgsSample, False, sysObj)

    # ----------------------------------------------------- #
Beispiel #16
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)
wait(3)
log.info("No panicking detected, continuing...")

#######################################################################
# List of samples and their plotting colours
#######################################################################

#--------------------------
# Diboson
#--------------------------
# NB: note that theoSys on diboson are applied on the level of the region definitions,
# since we have one for the SR and one for the CR
dibosonSample = Sample(zlFitterConfig.dibosonSampleName, kRed+3)
dibosonSample.setTreeName("Diboson_SRAll")
dibosonSample.setFileList(dibosonFiles)
dibosonSample.setStatConfig(zlFitterConfig.useStat)

#--------------------------
# QCD
#--------------------------
qcdSample = Sample(zlFitterConfig.qcdSampleName, kOrange+2)
if zlFitterConfig.useDDQCDsample:#normWeight is 0 => remove it
    qcdSample.setTreeName("Data_SRAll")
else :
    qcdSample.setTreeName("QCD_SRAll")
qcdSample.setNormFactor("mu_"+zlFitterConfig.qcdSampleName, 1., 0., 50000000.)
qcdSample.setFileList(qcdFiles)
qcdSample.setStatConfig(zlFitterConfig.useStat)

qcdWeight = 1
nJets = channel.nJets
Beispiel #18
0
#     efake_sample = Sample("efake15", color("efake"))
#     jfake_sample = Sample("jfake15", color("jfake"))
# elif data_name == 'data16':
#     efake_sample = Sample("efake16", color("efake"))
#     jfake_sample = Sample("jfake16", color("jfake"))
# else: # should be 'data'
efake_sample = Sample("efake", color("efake"))
jfake_sample = Sample("jfake", color("jfake"))

# Data
data_sample = Sample('data', ROOT.kBlack)
data_sample.setData()

# stat uncertainty
# data_sample.setStatConfig(useStat)
wjets_sample.setStatConfig(useStat)
zjets_sample.setStatConfig(useStat)
wgamma_sample.setStatConfig(useStat)
zllgamma_sample.setStatConfig(useStat)
znunugamma_sample.setStatConfig(useStat)
ttbar_sample.setStatConfig(useStat)
ttbarg_sample.setStatConfig(useStat)
photonjet_sample.setStatConfig(useStat)
multijet_sample.setStatConfig(useStat)
diphoton_sample.setStatConfig(useStat)
vqqgamma_sample.setStatConfig(useStat)

efake_sample.setStatConfig(False)
jfake_sample.setStatConfig(False)

data_samples = [
Beispiel #19
0
                                     high = [nominal_weight_bkg, '(1+0.5*(ht_signal>500))'],
                                     low  = [nominal_weight_bkg, '(1-0.5*(ht_signal>500))'],
                                     type = 'weight',
                                     method = 'overallSys')

# --------------------------------------------
# - List of samples and their plotting colours
# --------------------------------------------
sample_list_bkg  = []
sample_list_data = []
sample_list_sig  = []

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Other
other_sample = Sample("Other", kAzure+8)
other_sample.setStatConfig(use_stat)
other_sample.setNormByTheory()
sample_list_bkg.append(other_sample)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# single top
single_top_sample = Sample("SingleTop", kGreen-1)

single_top_sample.setStatConfig(use_stat)
single_top_sample.setNormByTheory()
sample_list_bkg.append(single_top_sample)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Z/gamma*
z_sample = Sample("ZGamma", kRed+1 )
Beispiel #20
0
        # use_this = False
        # for oksampk in ok_samples :
        #    if oksampk in s : use_this = True
        # if not use_this : continue
        # if "225" not in s : continue
        # if "135" not in s : continue
        # s_ = s.replace(".0", "")
        s_ = s
        extlx = configMgr.addFitConfigClone(tlx, "Sig_%s" % s_)

        userPrint(" > Adding signal sample to exclusion fit config : %s" % s)

        sigSample_ = Sample(s, kPink)
        sigSample_.setFileList(signal_files)
        sigSample_.setNormByTheory()
        sigSample_.setStatConfig(not runOptions.doSplitMCsys())
        if runOptions.doSplitMCsys():
            sigSample_.addSystematic(sysObj.mcstat_SIG)
        ## set the signal weight to be the weight with no PUPW
        sigSample_.weights = ["eventweightNOPUPW"]

        if runOptions.doTheoryBand():  ### TODO check if we need the configMgr setRunOnlyNominalXSec
            sigXSSyst = Systematic(
                "SigXSec", ["eventweightNOPUPW"], 1.07, 0.93, "user", "overallSys"
            )  ### TODO add xsec util to grab the uncertainties on xsec (rather than storing in tree)
            # sigXSSyst = Systematic("SigXSec", configMgr.weights, 1.07, 0.93, "user", "overallSys") ### TODO add xsec util to grab the uncertainties on xsec (rather than storing in tree)
            sigSample_.addSystematic(sigXSSyst)

        ## add systematics
        sigSample_ = addSys(sigSample_, False, sysObj, True)