Exemple #1
0
    catSel = ["all"]

setup = Setup(year=args.year, photonSelection=False, checkOnly=True)
estimators = EstimatorList(setup)
allProcesses = [
    item for item in allProcesses
    if not "fakes-DD" in item and not "_had" in item
]
allEstimators = estimators.constructEstimatorList(allProcesses)
mc = list(set([e.name.split("_")[0] for e in allEstimators]))

if not args.noData:
    allEstimators += [
        DataObservation(name="Data",
                        process=setup.processes["Data"],
                        cacheDir=setup.defaultCacheDir())
    ]

if args.controlRegion:
    setup = setup.sysClone(parameters=CR_para)


def wrapper(arg):
    r, channel, setup, estimate, cat, est = arg
    estimate.initCache(setup.defaultCacheDir())
    if estimate.name == "Data" and blind:
        res = u_float(0, 0)
    else:
        res = estimate.cachedEstimate(r,
                                      channel,
                                      setup,
Exemple #2
0
            ).getYieldFromDraw(selectionString=cut, weightString=weight))

if __name__ == "__main__":
    from TTGammaEFT.Analysis.regions import regionsTTG, noPhotonRegionTTG, inclRegionsTTG
    from TTGammaEFT.Analysis.SetupHelpers import allRegions
    from TTGammaEFT.Analysis.Setup import Setup

    print "lowPT"
    r = regionsTTG[0]

    setup = Setup(year=2016, photonSelection=True)
    setup = setup.sysClone(parameters=allRegions["VG3"]["parameters"])

    estimate = MCBasedEstimate(name="TTG_gen",
                               process=setup.processes["TTG_gen"])
    estimate.initCache(setup.defaultCacheDir())
    res = estimate.TuneSystematic(r, "e", setup)

    #    res = estimate._estimate( r, "e", setup, overwrite=False )
    print "TTG", res

    estimate = MCBasedEstimate(name="TTG_gen",
                               process=setup.processes["TTG_gen"])
    estimate.initCache(setup.defaultCacheDir())
    #    res = estimate._estimate( r, "e", setup, overwrite=False )
    print "TTG_gen", res

    estimate = MCBasedEstimate(name="TTG_misID",
                               process=setup.processes["TTG_misID"])
    estimate.initCache(setup.defaultCacheDir())
    res = estimate._estimate(r, "e", setup, overwrite=False)
Exemple #3
0
        inclRegionsTTG = inclRegionsTTGloose
        regionsTTG = regionsTTGloose
        blind = args.year != 2016
    ptDict = {str(inclRegionsTTG[0]):"all", str(regionsTTG[0]):"lowPT", str(regionsTTG[1]):"medPT", str(regionsTTG[2]):"highPT"}
    catSel = ["all","gen","misID","had"]
else:
    ptDict = {str(noPhotonRegionTTG[0]):"all"}
    catSel = ["all"]

setup          = Setup(year=args.year, photonSelection=False, checkOnly=True)
estimators     = EstimatorList(setup)
allEstimators  = estimators.constructEstimatorList( allProcesses )
mc  = list(set([e.name.split("_")[0] for e in allEstimators]))

if not args.noData:
    allEstimators += [DataObservation(name="Data", process=setup.processes["Data"], cacheDir=setup.defaultCacheDir())]

if args.controlRegion:
    setup = setup.sysClone(parameters=CR_para)

def wrapper(arg):
        r,channel,setup,estimate,cat,est = arg
        estimate.initCache(setup.defaultCacheDir())
        if estimate.name == "Data" and blind:
            res = u_float(0,0)
        else:
            res = estimate.cachedEstimate(r, channel, setup, overwrite=False, checkOnly=True)
        if args.removeNegative and res < 0: res = u_float(0,0)
        return est, str(r), cat, channel, res.tuple()

if args.controlRegion and args.controlRegion.startswith('DY'):
        toRes = estimateTo.writeToCache(r,
                                        channel,
                                        setup,
                                        res,
                                        signalAddon=addon,
                                        overwrite=args.overwrite)
    else:
        print "Did not copy: ", args.selectEstimator, estimateFrom.uniqueKey(
            r, channel, setup), args.controlRegion
    return (estimateTo.uniqueKey(r, channel, setup), res)


#fromDir = "/eos/vbc/incoming/user/lukas.lechner/TTGammaEFT/cache_read/analysis/%i/estimates/"%args.year
fromDir = "/scratch/lukas.lechner/TTGammaEFT/cache_read/analysis/%i/estimates" % args.year
print "copy from: %s" % fromDir
print "copy to: %s" % setup.defaultCacheDir()

estimateTo = copy.deepcopy(estimateFrom)
estimateFrom.initCache(fromDir)
estimateTo.initCache(setup.defaultCacheDir())

if "all" in channels: channels = ["e", "mu"]
jobs = []
for channel in channels:
    for (i, r) in enumerate(allPhotonRegions):
        #        if args.selectRegion != i: continue
        jobs.append((r, channel, setup, None))
        if not estimateFrom.isData and not args.noSystematics:
            if "TTG" in args.selectEstimator:
                jobs.extend(estimateFrom.getSigSysJobs(r, channel, setup))
            else:
Exemple #5
0
extensions_ = ["pdf", "png", "root"]
plot_directory_ = os.path.join(plot_directory, 'QCDMCTFComp', str(args.year),
                               args.plot_directory, args.mode)
copyIndexPHP(plot_directory_)

if args.year == 2016: lumi_scale = 35.92
elif args.year == 2017: lumi_scale = 41.53
elif args.year == 2018: lumi_scale = 59.74
elif args.year == "RunII": lumi_scale = 35.92 + 41.53 + 59.74

parameters0b0p = allRegions["WJets2"]["parameters"]
setup0b0p = Setup(year=args.year, photonSelection=False, checkOnly=True)
estimators0b0p = EstimatorList(setup0b0p, processes=["QCD-DD"])
estimate0b0p = getattr(estimators0b0p, "QCD-DD")
setup0b0p = setup0b0p.sysClone(parameters=parameters0b0p)
estimate0b0p.initCache(setup0b0p.defaultCacheDir())

parameters1b0p = allRegions["TT2"]["parameters"]
setup1b0p = Setup(year=args.year, photonSelection=False, checkOnly=True)
estimators1b0p = EstimatorList(setup1b0p, processes=["QCD-DD"])
estimate1b0p = getattr(estimators1b0p, "QCD-DD")
setup1b0p = setup1b0p.sysClone(parameters=parameters1b0p)
estimate1b0p.initCache(setup1b0p.defaultCacheDir())

cachedTF = {}
cachedTF["0b0p"] = {}
cachedTF["1b0p"] = {}
cachedTF["0b1p"] = {}
cachedTF["1b1p"] = {}
for nJet in [(2, 2), (3, 3), (4, -1)]:
    nj = str(nJet[0])
inclEstimate = "TTG_NLO"

# setup and sample
parameters = allRegions["SR3"]["parameters"]
channels = allRegions["SR3"]["channels"]
photonSelection = not allRegions["SR3"]["noPhotonCR"]
allPhotonRegions = allRegions["SR3"]["inclRegion"] + allRegions["SR3"][
    "regions"] if photonSelection else allRegions["SR3"]["regions"]

setup = Setup(year="RunII", photonSelection=photonSelection,
              private=True)  #photonselection always false for qcd es$
setup = setup.sysClone(parameters=parameters)
estimates = EstimatorList(setup, processes=["TTG_NLO_gen", inclEstimate])
estimate = getattr(estimates, "TTG_NLO_gen")
estimate.initCache(setup.defaultCacheDir() + "/PDF")

scale_indices = [0, 1, 3, 5, 7, 8]  #4 central?
pdf_indices = range(100)
aS_variations = ["abs(LHEPdfWeight[101])", "abs(LHEPdfWeight[102])"]
scale_variations = ["abs(LHEScaleWeight[%i])" % i for i in scale_indices]
PDF_variations = ["abs(LHEPdfWeight[%i])" % i for i in pdf_indices]

PDF_unc = []
Scale_unc = []
PS_unc = []
ISR_unc = []
FSR_unc = []

c = "all"
sigma_central = estimate.cachedEstimate(noRegions[0], c, setup)