def applySplitNonClosure(fakeFactorsMC, fakeFactorsData):
    nonClosureFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/Uncertainties/Closures/results/nonClosures_split.root"
    formShift = '[{SHIFT}]*[{NOM}]'
    for i in xrange(4):
        nonClosureQCDSS = createRawComponent(
            Name="QCDSSNonClosure{I}_VsMVis".format(I=i),
            File=nonClosureFile,
            Type="1DGraph",
            Object="QCDSS_Histo_Smooth_Ratio_{I}".format(I=i))
        ## MC
        fakeFactorQCDSS = findComponent("Weight_QCDSS_" + fakeFactor,
                                        fakeFactorsMC)
        fakeFactorQCDSS.addSystematic(
            'NonClosure', 'ShiftNonClosure_QCDSS_{I}'.format(I=i),
            createCombinedComponent(Name='',
                                    Form=formShift,
                                    SHIFT=nonClosureQCDSS,
                                    NOM=fakeFactorQCDSS))
        ## Data
        fakeFactorQCDSS = findComponent("Weight_QCDSS_" + fakeFactor,
                                        fakeFactorsData)
        fakeFactorQCDSS.addSystematic(
            'NonClosure', 'ShiftNonClosure_QCDSS_{I}'.format(I=i),
            createCombinedComponent(Name='',
                                    Form=formShift,
                                    SHIFT=nonClosureQCDSS,
                                    NOM=fakeFactorQCDSS))
def create(fakeFactorsMC, fakeFactorsData):
    fractionsFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/ComputeBackgroundFractions/results/backgroundFraction_SS_Iso_Medium_mvis_vs_mt.root"
    #formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}])+[{W_Z}]*([{ZJ}]+[{VV}])'
    formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}]+[{ZJ}]+[{VV}])'
    fractionsW = createRawComponent(
        Name="Fraction_SS_W_VsMVisMT",
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_W_Nom")
    fractionsQCD = createRawComponent(
        Name="Fraction_SS_QCD_VsMVisMT",
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_QCD_Nom")
    fractionsTT = createRawComponent(
        Name="Fraction_SS_TT_VsMVisMT",
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_TT_Nom")
    fractionsZJ = createRawComponent(
        Name="Fraction_SS_ZJ_VsMVisMT",
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_ZJ_Nom")
    fractionsVV = createRawComponent(
        Name="Fraction_SS_VV_VsMVisMT",
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_VV_Nom")

    fakeFactorsMC.append(
        createCombinedComponent(
            Name="Weight_CombinedSS_" + fakeFactor,
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_" + fakeFactor, fakeFactorsMC),
            W_W=findComponent("Weight_HighMTSS_" + fakeFactor, fakeFactorsMC),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsMC),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV))
    fakeFactorsData.append(
        createCombinedComponent(
            Name="Weight_CombinedSS_" + fakeFactor,
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_" + fakeFactor, fakeFactorsData),
            W_W=findComponent("Weight_HighMTSS_" + fakeFactor,
                              fakeFactorsData),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsData),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV))
    return [fractionsTT, fractionsW, fractionsVV, fractionsZJ, fractionsQCD]
def applyNonClosure(fakeFactorsMC, fakeFactorsData):
    nonClosureFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/Uncertainties/Closures/results/nonClosures.root"
    formShift = '[{SHIFT}]*[{NOM}]'
    ## MC
    #nonClosureZMuMu = createRawComponent(
    #Name="ZMuMuNonClosure_VsMVis",
    #File=nonClosureFile,
    #Type="1DGraph",
    #Object="ZMuMu_Histo_Smooth_Ratio"
    #)
    #fakeFactorZMuMu = findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsMC)
    #fakeFactorZMuMu.addSystematic(
    #'NonClosure',
    #'ShiftNonClosure_ZMuMu',
    #createCombinedComponent(
    #Name='',
    #Form=formShift,
    #SHIFT=nonClosureZMuMu,
    #NOM=fakeFactorZMuMu
    #)
    #)
    #
    nonClosureQCDSS = createRawComponent(Name="QCDSSNonClosure_VsMVis",
                                         File=nonClosureFile,
                                         Type="1DGraph",
                                         Object="QCDSS_Histo_Smooth_Ratio")
    fakeFactorQCDSS = findComponent("Weight_QCDSS_" + fakeFactor,
                                    fakeFactorsMC)
    fakeFactorQCDSS.addSystematic(
        'NonClosure', 'ShiftNonClosure_QCDSS',
        createCombinedComponent(Name='',
                                Form=formShift,
                                SHIFT=nonClosureQCDSS,
                                NOM=fakeFactorQCDSS))
    ## Data
    #fakeFactorZMuMu = findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsData)
    #fakeFactorZMuMu.addSystematic(
    #'NonClosure',
    #'ShiftNonClosure_ZMuMu',
    #createCombinedComponent(
    #Name='',
    #Form=formShift,
    #SHIFT=nonClosureZMuMu,
    #NOM=fakeFactorZMuMu
    #)
    #)
    #
    fakeFactorQCDSS = findComponent("Weight_QCDSS_" + fakeFactor,
                                    fakeFactorsData)
    fakeFactorQCDSS.addSystematic(
        'NonClosure', 'ShiftNonClosure_QCDSS',
        createCombinedComponent(Name='',
                                Form=formShift,
                                SHIFT=nonClosureQCDSS,
                                NOM=fakeFactorQCDSS))
Beispiel #4
0
def applyNonClosure(fakeFactorsMC, fakeFactorsData):
    nonClosureFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/Uncertainties/Closures/results/nonClosures.root"
    nonClosureSSFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/Uncertainties/Closures/results/nonClosures_SS.root"
    formShift = '[{SHIFT}]*[{NOM}]'
    nonClosureHighMT = createRawComponent(Name="HighMTNonClosure_VsMVis",
                                          File=nonClosureFile,
                                          Type="1DGraph",
                                          Object="HighMT_Histo_Smooth_Ratio")
    nonClosureHighMTSS = createRawComponent(
        Name="HighMTSSNonClosure_VsMVis",
        File=nonClosureSSFile,
        Type="1DGraph",
        Object="HighMTSS_Histo_Smooth_Ratio")
    ## MC
    fakeFactorHighMT = findComponent("Weight_HighMT_" + fakeFactor,
                                     fakeFactorsMC)
    fakeFactorHighMT.addSystematic(
        'NonClosure', 'ShiftNonClosure_HighMT',
        createCombinedComponent(Name='',
                                Form=formShift,
                                SHIFT=nonClosureHighMT,
                                NOM=fakeFactorHighMT))
    fakeFactorHighMTSS = findComponent("Weight_HighMTSS_" + fakeFactor,
                                       fakeFactorsMC)
    fakeFactorHighMTSS.addSystematic(
        'NonClosure', 'ShiftNonClosure_HighMTSS',
        createCombinedComponent(Name='',
                                Form=formShift,
                                SHIFT=nonClosureHighMTSS,
                                NOM=fakeFactorHighMTSS))
    ## Data
    fakeFactorHighMT = findComponent("Weight_HighMT_" + fakeFactor,
                                     fakeFactorsData)
    fakeFactorHighMT.addSystematic(
        'NonClosure', 'ShiftNonClosure_HighMT',
        createCombinedComponent(Name='',
                                Form=formShift,
                                SHIFT=nonClosureHighMT,
                                NOM=fakeFactorHighMT))
    fakeFactorHighMTSS = findComponent("Weight_HighMTSS_" + fakeFactor,
                                       fakeFactorsData)
    fakeFactorHighMTSS.addSystematic(
        'NonClosure', 'ShiftNonClosure_HighMTSS',
        createCombinedComponent(Name='',
                                Form=formShift,
                                SHIFT=nonClosureHighMTSS,
                                NOM=fakeFactorHighMTSS))
def create(fakeFactorsMC, fakeFactorsData):
    highMTCorrectionFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/ComputeMTCorrection/results/mtCorrections.root"
    formCorrection = '[{CORR}]*[{RAW}]'
    highMTCorrection = createRawComponent(
        Name="HighMTCorr_VsMT" ,
        File=highMTCorrectionFile,
        Type="1DGraph",
        Object="mt_correction"
    )
    ## MC
    fakeFactorsMC.append(
        createCombinedComponent(
            Name="Weight_HighMT_"+fakeFactor,
            Form=formCorrection,
            CORR=highMTCorrection,
            RAW=findComponent("Weight_HighMTRaw_"+fakeFactor,fakeFactorsMC)
        )
    )
    fakeFactorsMC.append(
        createCombinedComponent(
            Name="Weight_HighMTSS_"+fakeFactor,
            Form=formCorrection,
            CORR=highMTCorrection,
            RAW=findComponent("Weight_HighMTSSRaw_"+fakeFactor,fakeFactorsMC)
        )
    )
    ## Data
    fakeFactorsData.append(
        createCombinedComponent(
            Name="Weight_HighMT_"+fakeFactor,
            Form=formCorrection,
            CORR=highMTCorrection,
            RAW=findComponent("Weight_HighMTRaw_"+fakeFactor,fakeFactorsData)
        )
    )
    fakeFactorsData.append(
        createCombinedComponent(
            Name="Weight_HighMTSS_"+fakeFactor,
            Form=formCorrection,
            CORR=highMTCorrection,
            RAW=findComponent("Weight_HighMTSSRaw_"+fakeFactor,fakeFactorsData)
        )
    )
    return highMTCorrection
Beispiel #6
0
def create(fakeFactorsMC, fakeFactorsData):
    highMTCorrectionFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/ComputeMTCorrection/results/mtCorrections.root"
    formCorrection = '[{CORR}]*[{RAW}]'
    highMTCorrection = createRawComponent(Name="HighMTCorr_VsMT",
                                          File=highMTCorrectionFile,
                                          Type="1DGraph",
                                          Object="mt_correction")
    ## MC
    fakeFactorsMC.append(
        createCombinedComponent(Name="Weight_HighMT_" + fakeFactor,
                                Form=formCorrection,
                                CORR=highMTCorrection,
                                RAW=findComponent(
                                    "Weight_HighMTRaw_" + fakeFactor,
                                    fakeFactorsMC)))
    fakeFactorsMC.append(
        createCombinedComponent(Name="Weight_HighMTSS_" + fakeFactor,
                                Form=formCorrection,
                                CORR=highMTCorrection,
                                RAW=findComponent(
                                    "Weight_HighMTSSRaw_" + fakeFactor,
                                    fakeFactorsMC)))
    ## Data
    fakeFactorsData.append(
        createCombinedComponent(Name="Weight_HighMT_" + fakeFactor,
                                Form=formCorrection,
                                CORR=highMTCorrection,
                                RAW=findComponent(
                                    "Weight_HighMTRaw_" + fakeFactor,
                                    fakeFactorsData)))
    fakeFactorsData.append(
        createCombinedComponent(Name="Weight_HighMTSS_" + fakeFactor,
                                Form=formCorrection,
                                CORR=highMTCorrection,
                                RAW=findComponent(
                                    "Weight_HighMTSSRaw_" + fakeFactor,
                                    fakeFactorsData)))
    return highMTCorrection
def createShift(group, name, shift, fractionsFile, fakeFactorsMC,
                fakeFactorsData):
    #formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}])+[{W_Z}]*([{ZJ}]+[{VV}])'
    formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}]+[{ZJ}]+[{VV}])'
    fractionsW = createRawComponent(
        Name="Fraction_SS_W_VsMVisMT_{SHIFT}".format(SHIFT=shift),
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_W_{SHIFT}".
        format(SHIFT=shift))
    fractionsQCD = createRawComponent(
        Name="Fraction_SS_QCD_VsMVisMT_{SHIFT}".format(SHIFT=shift),
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_QCD_{SHIFT}".
        format(SHIFT=shift))
    fractionsTT = createRawComponent(
        Name="Fraction_SS_TT_VsMVisMT_{SHIFT}".format(SHIFT=shift),
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_TT_{SHIFT}".
        format(SHIFT=shift))
    fractionsZJ = createRawComponent(
        Name="Fraction_SS_ZJ_VsMVisMT_{SHIFT}".format(SHIFT=shift),
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_ZJ_{SHIFT}".
        format(SHIFT=shift))
    fractionsVV = createRawComponent(
        Name="Fraction_SS_VV_VsMVisMT_{SHIFT}".format(SHIFT=shift),
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_VV_{SHIFT}".
        format(SHIFT=shift))
    ## MC
    fakeFactorCombined = findComponent("Weight_CombinedSS_" + fakeFactor,
                                       fakeFactorsMC)
    fakeFactorCombined.addSystematic(
        group,
        name,
        createCombinedComponent(
            Name='',
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_" + fakeFactor, fakeFactorsMC),
            W_W=findComponent("Weight_HighMTSS_" + fakeFactor, fakeFactorsMC),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsMC),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV))
    ## Data
    fakeFactorCombined = findComponent("Weight_CombinedSS_" + fakeFactor,
                                       fakeFactorsData)
    fakeFactorCombined.addSystematic(
        group,
        name,
        createCombinedComponent(
            Name='',
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_" + fakeFactor, fakeFactorsData),
            W_W=findComponent("Weight_HighMTSS_" + fakeFactor,
                              fakeFactorsData),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsData),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV))
Beispiel #8
0

data = []
mc = []
rawFakeFactors.create(mc,data)
mtcorr = mTCorrectedFakeFactors.create(mc,data)
combinedSSFakeFactors.create(mc,data)

rawFakeFactors.applySplitNonClosure(mc,data)
mTCorrectedFakeFactors.applySplitNonClosure(mc,data)
mTCorrectedFakeFactors.applyStat(mtcorr)
mTCorrectedFakeFactors.applyBinSys(mtcorr)
combinedSSFakeFactors.applySys(mc,data)
#combinedFakeFactors.applyStat(mc,data)

combinedFakeFactor = findComponent('Weight_CombinedSS_Iso_Medium_VsPtDecay', data) 



for comp in combinedFakeFactor.components:
    # 1st level
    for group,sys in comp.systematics.items():
        for s in sys:
            ffsys = combinedFakeFactor.copy()       
            ffsys.replaceComponent(comp,s)
            combinedFakeFactor.addSystematic(group, s.name.replace(comp.name+'_',''), ffsys)
    ## 2nd level
    for comp2 in comp.components:
        for group,sys in comp2.systematics.items():
            for s in sys:
                compsys = comp.copy()       

data = []
mc = []
rawFakeFactors.create(mc, data)
mtcorr = mTCorrectedFakeFactors.create(mc, data)
combinedFakeFactors.create(mc, data)

rawFakeFactors.applySplitNonClosure(mc, data)
mTCorrectedFakeFactors.applySplitNonClosure(mc, data)
mTCorrectedFakeFactors.applyStat(mtcorr)
mTCorrectedFakeFactors.applyBinSys(mtcorr)
combinedFakeFactors.applySys(mc, data)
# combinedFakeFactors.applyStat(mc,data)

combinedFakeFactor = findComponent("Weight_Combined_Iso_Medium_VsPtDecay", data)


for comp in combinedFakeFactor.components:
    # 1st level
    for group, sys in comp.systematics.items():
        for s in sys:
            ffsys = combinedFakeFactor.copy()
            ffsys.replaceComponent(comp, s)
            combinedFakeFactor.addSystematic(group, s.name.replace(comp.name + "_", ""), ffsys)
    ## 2nd level
    for comp2 in comp.components:
        for group, sys in comp2.systematics.items():
            for s in sys:
                compsys = comp.copy()
                compsys.replaceComponent(comp2, s)
def createShift(group, name, shift, fractionsFile, fakeFactorsMC, fakeFactorsData):
    #formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}])+[{W_Z}]*([{ZJ}]+[{VV}])'
    formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}]+[{ZJ}]+[{VV}])'
    fractionsW   = createRawComponent(
        Name="Fraction_SS_W_VsMVisMT_{SHIFT}".format(SHIFT=shift)  ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_W_{SHIFT}".format(SHIFT=shift)
    )
    fractionsQCD = createRawComponent(
        Name="Fraction_SS_QCD_VsMVisMT_{SHIFT}".format(SHIFT=shift),
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_QCD_{SHIFT}".format(SHIFT=shift)
    )
    fractionsTT  = createRawComponent(
        Name="Fraction_SS_TT_VsMVisMT_{SHIFT}".format(SHIFT=shift) ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_TT_{SHIFT}".format(SHIFT=shift)
    )
    fractionsZJ  = createRawComponent(
        Name="Fraction_SS_ZJ_VsMVisMT_{SHIFT}".format(SHIFT=shift) ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_ZJ_{SHIFT}".format(SHIFT=shift)
    )
    fractionsVV  = createRawComponent(
        Name="Fraction_SS_VV_VsMVisMT_{SHIFT}".format(SHIFT=shift) ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_VV_{SHIFT}".format(SHIFT=shift)
    )
    ## MC
    fakeFactorCombined = findComponent("Weight_CombinedSS_"+fakeFactor,fakeFactorsMC)
    fakeFactorCombined.addSystematic(
        group,
        name,
        createCombinedComponent(
            Name='',
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_"+fakeFactor,fakeFactorsMC),
            W_W=findComponent("Weight_HighMTSS_"+fakeFactor,fakeFactorsMC),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsMC),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV
        )
    )
    ## Data
    fakeFactorCombined = findComponent("Weight_CombinedSS_"+fakeFactor,fakeFactorsData)
    fakeFactorCombined.addSystematic(
        group,
        name,
        createCombinedComponent(
            Name='',
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_"+fakeFactor,fakeFactorsData),
            W_W=findComponent("Weight_HighMTSS_"+fakeFactor,fakeFactorsData),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsData),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV
        )
    )
def create(fakeFactorsMC, fakeFactorsData):
    fractionsFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/ComputeBackgroundFractions/results/backgroundFraction_SS_Iso_Medium_mvis_vs_mt.root"
    #formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}])+[{W_Z}]*([{ZJ}]+[{VV}])'
    formCombined = '[{W_QCD}]*[{QCD}]+[{W_W}]*([{W}]+[{TT}]+[{ZJ}]+[{VV}])'
    fractionsW   = createRawComponent(
        Name="Fraction_SS_W_VsMVisMT"  ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_W_Nom"
    )
    fractionsQCD = createRawComponent(
        Name="Fraction_SS_QCD_VsMVisMT",
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_QCD_Nom"
    )
    fractionsTT  = createRawComponent(
        Name="Fraction_SS_TT_VsMVisMT" ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_TT_Nom"
    )
    fractionsZJ  = createRawComponent(
        Name="Fraction_SS_ZJ_VsMVisMT" ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_ZJ_Nom"
    )
    fractionsVV  = createRawComponent(
        Name="Fraction_SS_VV_VsMVisMT" ,
        File=fractionsFile,
        Type="2DHisto",
        Object="h_backgroundFraction_SS_Iso_Medium_mvis_vs_mt_VV_Nom"
    )

    fakeFactorsMC.append(
        createCombinedComponent(
            Name="Weight_CombinedSS_"+fakeFactor,
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_"+fakeFactor,fakeFactorsMC),
            W_W=findComponent("Weight_HighMTSS_"+fakeFactor,fakeFactorsMC),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsMC),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV
        )
    )
    fakeFactorsData.append(
        createCombinedComponent(
            Name="Weight_CombinedSS_"+fakeFactor,
            Form=formCombined,
            W_QCD=findComponent("Weight_QCDSS_"+fakeFactor,fakeFactorsData),
            W_W=findComponent("Weight_HighMTSS_"+fakeFactor,fakeFactorsData),
            #W_Z=findComponent("Weight_ZMuMu_"+fakeFactor,fakeFactorsData),
            QCD=fractionsQCD,
            W=fractionsW,
            ZJ=fractionsZJ,
            TT=fractionsTT,
            VV=fractionsVV
        )
    )
    return [fractionsTT,fractionsW,fractionsVV,fractionsZJ,fractionsQCD]
def applyNonClosure(fakeFactorsMC, fakeFactorsData):
    nonClosureFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/Uncertainties/Closures/results/nonClosures.root"
    nonClosureSSFile = "/afs/cern.ch/user/j/jsauvan/workspace/Projects/Htautau_Run2/Studies/FakeRate/Uncertainties/Closures/results/nonClosures_SS.root"
    formShift = '[{SHIFT}]*[{NOM}]'
    nonClosureHighMT = createRawComponent(
        Name="HighMTNonClosure_VsMVis",
        File=nonClosureFile,
        Type="1DGraph",
        Object="HighMT_Histo_Smooth_Ratio"
    )
    nonClosureHighMTSS = createRawComponent(
        Name="HighMTSSNonClosure_VsMVis",
        File=nonClosureSSFile,
        Type="1DGraph",
        Object="HighMTSS_Histo_Smooth_Ratio"
    )
    ## MC
    fakeFactorHighMT = findComponent("Weight_HighMT_"+fakeFactor,fakeFactorsMC)
    fakeFactorHighMT.addSystematic(
        'NonClosure',
        'ShiftNonClosure_HighMT',
        createCombinedComponent(
            Name='',
            Form=formShift,
            SHIFT=nonClosureHighMT,
            NOM=fakeFactorHighMT
        )
    )
    fakeFactorHighMTSS = findComponent("Weight_HighMTSS_"+fakeFactor,fakeFactorsMC)
    fakeFactorHighMTSS.addSystematic(
        'NonClosure',
        'ShiftNonClosure_HighMTSS',
        createCombinedComponent(
            Name='',
            Form=formShift,
            SHIFT=nonClosureHighMTSS,
            NOM=fakeFactorHighMTSS
        )
    )
    ## Data
    fakeFactorHighMT = findComponent("Weight_HighMT_"+fakeFactor,fakeFactorsData)
    fakeFactorHighMT.addSystematic(
        'NonClosure',
        'ShiftNonClosure_HighMT',
        createCombinedComponent(
            Name='',
            Form=formShift,
            SHIFT=nonClosureHighMT,
            NOM=fakeFactorHighMT
        )
    )
    fakeFactorHighMTSS = findComponent("Weight_HighMTSS_"+fakeFactor,fakeFactorsData)
    fakeFactorHighMTSS.addSystematic(
        'NonClosure',
        'ShiftNonClosure_HighMTSS',
        createCombinedComponent(
            Name='',
            Form=formShift,
            SHIFT=nonClosureHighMTSS,
            NOM=fakeFactorHighMTSS
        )
    )