Exemplo n.º 1
0
def plotPU(category):

    MJArray = [
        200., 230., 260.0, 290.0, 320.0, 350.0, 390.0, 430.0, 470.0, 510.0,
        550.0, 590.0, 640.0, 690.0, 740.0, 790.0, 840.0, 900.0, 960.0, 1020.0,
        1090.0, 1160.0, 1250.0
    ]
    MVArray = [250, 300, 350, 400, 500, 600, 1000]

    theArray = MJArray
    if category == 'monoV':
        theArray = MVArray

    plotter.ResetWeight()
    plotter.AddWeight(cuts.cut(category, 'signal') + '* (mcWeight)')
    plotter.AddWeight(cuts.cut(category, 'signal') + '* (mcWeight * puWeight)')
    plotter.AddWeight(
        cuts.cut(category, 'signal') + '* (mcWeight * puWeightOff)')

    plotter.SetDefaultExpr('met')
    plotter.MakeCanvas('~/www/plots/160314/' + category,
                       len(theArray) - 1, array('d', theArray), 'MET [GeV]',
                       'Events/GeV', True)
    plotter.SetDefaultExpr('npv')
    plotter.MakeCanvas('~/www/plots/160314/NPV_' + category, 30, 0, 30, 'NPV',
                       'Events', False)
Exemplo n.º 2
0
def RunPlots(categories):
    cutList = [
        'nocut', 'nocut_nsmalljets', 'full', 'full_highpt', 'full_massp_tau21'
    ]
    for move in range(8):
        cutList.append('full_' + str(move * 0.1))

    MakePlots(categories, cutList, SetupArgs())

    plotter.SetDefaultWeight(cuts.cut('semilep', 'full_nopt'))
    plotter.SetMCWeight('(fatjetPtSmearedUp > 250) * (' +
                        cuts.defaultMCWeight + ')')
    plotter.SetDataWeight('(fatjetPt > 250)')
    plotter.SetDataExpression('fatjetPrunedML2L3')
    plotter.SetDefaultExpr('fatjetPrunedML2L3SmearedUp')
    plotter.MakeCanvas('smearedup_mass', 25, 0, 250,
                       'Fat Jet Pruned Mass [GeV]', 'Events/1.0')

    plotter.SetDataExpression('')
    plotter.SetDefaultExpr('fatjettau21')
    plotter.MakeCanvas('smearedup_tau21', 25, 0, 1.5, '#tau_{2}/#tau_{1}',
                       'Events/1.0')

    plotter.SetMakeRatio(False)
    MakePlots(
        categories, cutList,
        [['fatjetDRGenW', 25, 0, 5, '#Delta R from Gen W', 'Events/1.0']])
    plotter.SetMakeRatio(True)
Exemplo n.º 3
0
def plotPU(category):

    MJArray = [200., 230., 260.0, 290.0, 320.0, 350.0, 390.0, 430.0, 470.0, 510.0, 550.0, 590.0, 640.0, 690.0, 740.0, 790.0, 840.0, 900.0, 960.0, 1020.0, 1090.0, 1160.0, 1250.0]
    MVArray = [250,300,350,400,500,600,1000]

    theArray = MJArray
    if category == 'monoV':
        theArray = MVArray

    plotter.ResetWeight()
    plotter.AddWeight(cuts.cut(category,'signal') + '* (mcWeight)')
    plotter.AddWeight(cuts.cut(category,'signal') + '* (mcWeight * puWeight)')
    plotter.AddWeight(cuts.cut(category,'signal') + '* (mcWeight * puWeightOff)')

    plotter.SetDefaultExpr('met')
    plotter.MakeCanvas('~/www/plots/160314/' + category,len(theArray) - 1,array('d',theArray),'MET [GeV]','Events/GeV',True)
    plotter.SetDefaultExpr('npv')
    plotter.MakeCanvas('~/www/plots/160314/NPV_' + category,30,0,30,'NPV','Events',False)
Exemplo n.º 4
0
def RunPlots(categories):
    cutList = ['nocut', 'nocut_nsmalljets', 'full', 'full_highpt', 'full_massp_tau21']
    for move in range(8):
        cutList.append('full_' + str(move * 0.1))

    MakePlots(categories, cutList, SetupArgs())

    plotter.SetDefaultWeight(cuts.cut('semilep', 'full_nopt'))
    plotter.SetMCWeight('(fatjetPtSmearedUp > 250) * (' + cuts.defaultMCWeight + ')')
    plotter.SetDataWeight('(fatjetPt > 250)')
    plotter.SetDataExpression('fatjetPrunedML2L3')
    plotter.SetDefaultExpr('fatjetPrunedML2L3SmearedUp')
    plotter.MakeCanvas('smearedup_mass', 25, 0, 250, 'Fat Jet Pruned Mass [GeV]', 'Events/1.0')

    plotter.SetDataExpression('')
    plotter.SetDefaultExpr('fatjettau21')
    plotter.MakeCanvas('smearedup_tau21', 25, 0, 1.5, '#tau_{2}/#tau_{1}', 'Events/1.0')

    plotter.SetMakeRatio(False)
    MakePlots(categories, cutList, [['fatjetDRGenW', 25, 0, 5, '#Delta R from Gen W', 'Events/1.0']])
    plotter.SetMakeRatio(True)
Exemplo n.º 5
0
def doBoth(addToRegion='', **kwargs):
    print('All mass')
    if addToRegion == '_nopt':
        histAnalysis.SetBaseCut(cuts.cut('semilep','full' + addToRegion) + ' && fatjetPtSmeared' + kwargs['which'] + ' > 250',
                                cuts.cut('semilep','full' + addToRegion) + ' && fatjetPt > 250')
    else:
        histAnalysis.SetBaseCut(cuts.cut('semilep','full' + addToRegion))
    histAnalysis.DoScaleFactors('n_tightlep',1,0,2)
    print('No low mass')

    if addToRegion == '_nopt':
        histAnalysis.SetBaseCut(cuts.cut('nolowmass','full' + addToRegion) + ' && fatjetPtSmeared' + kwargs['which'] + ' > 250',
                                cuts.cut('nolowmass','full' + addToRegion) + ' && fatjetPt > 250')
    else:
        histAnalysis.SetBaseCut(cuts.cut('nolowmass','full' + addToRegion))
    histAnalysis.DoScaleFactors('n_tightlep',1,0,2)
Exemplo n.º 6
0
def doBoth(addToRegion='', **kwargs):
    print('All mass')
    if addToRegion == '_nopt':
        histAnalysis.SetBaseCut(
            cuts.cut('semilep', 'full' + addToRegion) + ' && fatjetPtSmeared' +
            kwargs['which'] + ' > 250',
            cuts.cut('semilep', 'full' + addToRegion) + ' && fatjetPt > 250')
    else:
        histAnalysis.SetBaseCut(cuts.cut('semilep', 'full' + addToRegion))
    histAnalysis.DoScaleFactors('n_tightlep', 1, 0, 2)
    print('No low mass')

    if addToRegion == '_nopt':
        histAnalysis.SetBaseCut(
            cuts.cut('nolowmass', 'full' + addToRegion) +
            ' && fatjetPtSmeared' + kwargs['which'] + ' > 250',
            cuts.cut('nolowmass', 'full' + addToRegion) + ' && fatjetPt > 250')
    else:
        histAnalysis.SetBaseCut(cuts.cut('nolowmass', 'full' + addToRegion))
    histAnalysis.DoScaleFactors('n_tightlep', 1, 0, 2)
Exemplo n.º 7
0
            corr.SetMatchFileName(matchName)
        corr.Merge = merge
        applicator.AddCorrector(corr)

    for cat in [
            'boosted',
            'inclusive',
    ]:
        for region in ['tt', 'heavyz', 'lightz', 'signal']:
            _region = '%s__%s' % (cat, region)
            try:
                add_corr(
                    '%s_%s%s' % (_region, process, version),
                    MakeDatacards.expr[cat].get(
                        region, MakeDatacards.expr[cat]['default']),
                    cuts.cut(cat, region), rootfile, [
                        'shapes_fit_b/%s/%s' % (_region, process),
                        'shapes_prefit/%s/%s' % (_region, process)
                    ])
            except:
                pass

    if __name__ == '__main__':
        RunParallel(applicator, 'RunOnFile', [[f] for f in FileLists[process]])

# Put placeholder into Signal samples
for process in MakeDatacards.alltrees['signal']:
    applicator = Corrector.MakeApplicator(out_branch, True, 'events', 'events',
                                          10000)
    applicator.SetInDirectory(os.environ['CrombieInFilesDir'])
    if __name__ == '__main__':
Exemplo n.º 8
0
#!/usr/bin/env python

from CrombieTools.AnalysisTools.HistAnalysis import *
from CrombieTools.LoadConfig import cuts
import os

SetupFromEnv()

histAnalysis.AddDataFile('../Skim_170116/wscale_Data.root')
histAnalysis.SetBaseCut(cuts.cut('semilep','nocut'))
histAnalysis.SetMCWeight('(mcFactors/puWeight)')

histAnalysis.MakeReweightHist('puWeight_30fb_2016.root', 'puWeight', 'npv', 40, 0, 40)
Exemplo n.º 9
0
#! /usr/bin/env python

from CrombieTools.AnalysisTools.FitTools import *
from CrombieTools.LoadConfig import cuts

fitTools.SetDebugLevel(fitTools.eDebug)

SetupFromEnv()

fitTools.SetCategoryBranch('fatjet1QGMatching')
fitTools.AddCategory('Quark')
fitTools.AddCategory('Gluon')

fitTools.SetBaseCut(cuts.cut('photon', 'nocut') + ' && fatjet1tau21 < 0.4')
fitTools.SetDefaultExpr('fatjet1PrunedM')
fitTools.SetMCWeight('xsec_v2')
fitTools.SetSignalName('Signal')
fitTools.AddDataFile('fakescale_Data.root')

fitTools.FitCategories(0.0, 150.0, 'Pruned Mass [GeV]')
Exemplo n.º 10
0
#! /usr/bin/env python

from CrombieTools.PlotTools.PlotHists import plotter
from CrombieTools.PlotTools import AddOutDir
from CrombieTools.LoadConfig import cuts

from ROOT import TFile

infile = TFile(
    '/data/t3home000/dabercro/hbb/180208/ZH_HToBB_ZToNuNu_M125_13TeV_powheg_pythia8.root'
)

plotter.SetDefaultCut(
    '%s * (%s)' %
    (cuts.cut('ZvvHbb', 'signal'), cuts.dataMCCuts('signal', False)))
plotter.SetDefaultTree(infile.Get('events'))

plotter.AddExpr('cmva_hbb_m')
plotter.AddExpr('cmva_hbb_m_reg_old')
plotter.AddExpr('cmva_hbb_m_reg')

plotter.SetNormalizedHists(True)

plotter.AddLegendEntry('No Regression', 1, 2, 1)
plotter.AddLegendEntry('Old Regression', 2, 2, 1)
plotter.AddLegendEntry('New Regression', 3, 2, 1)

plotter.SetDebugLevel(2)

plotter.MakeCanvas(AddOutDir('regression'), 50, 50, 200, 'Dijet Mass', 'A.U.')
Exemplo n.º 11
0
           'monojet_VectorMonoW_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')
cChain.Add(signal_loc +
           'monojet_VectorMonoZ_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')

dFile = TFile(directory +
              'wscale_TTJets_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8.root')

plotter.AddTree(aChain)
plotter.AddTree(bChain)
plotter.AddTree(cChain)
plotter.AddTree(dFile.Get('events'))

plotter.SetNormalizedHists(True)

plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjetPt')
plotter.AddWeight('mcWeight')
plotter.AddWeight('mcWeight')
plotter.AddWeight('mcWeight')
plotter.AddWeight('(' + cuts.cut('semilep', 'full') + ')*(mcWeight)')

plotter.AddLegendEntry('VH Signal', 1, 2, 1)
plotter.AddLegendEntry('m_{#phi} = 500 GeV Signal', 2, 2, 2)
plotter.AddLegendEntry('m_{#phi} = 2000 GeV Signal', 3, 2, 3)
plotter.AddLegendEntry('W in tt', 4, 2, 4)

plotter.MakeCanvas('~/www/plots/160707/WPt_comparison', 17, 275, 700,
                   "p_{T} [GeV]", "A.U.")
Exemplo n.º 12
0
bChain.Add(signal_loc + 'monojet_VectorMonoZ_Mphi-500_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')

cChain = TChain('events','events_chainc')
cChain.Add(signal_loc + 'monojet_VectorMonoW_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')
cChain.Add(signal_loc + 'monojet_VectorMonoZ_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')

dFile = TFile(directory + 'wscale_TTJets_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8.root')

plotter.AddTree(aChain)
plotter.AddTree(bChain)
plotter.AddTree(cChain)
plotter.AddTree(dFile.Get('events'))

plotter.SetNormalizedHists(True)

plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjetPt')
plotter.AddWeight('mcWeight')
plotter.AddWeight('mcWeight')
plotter.AddWeight('mcWeight')
plotter.AddWeight('(' + cuts.cut('semilep','full') + ')*(mcWeight)')

plotter.AddLegendEntry('VH Signal',1,2,1)
plotter.AddLegendEntry('m_{#phi} = 500 GeV Signal',2,2,2)
plotter.AddLegendEntry('m_{#phi} = 2000 GeV Signal',3,2,3)
plotter.AddLegendEntry('W in tt',4,2,4)

plotter.MakeCanvas('~/www/plots/160707/WPt_comparison',17,275,700,"p_{T} [GeV]","A.U.")
Exemplo n.º 13
0
#!/usr/bin/env python

from CrombieTools.AnalysisTools.HistAnalysis import *
from CrombieTools.LoadConfig import cuts

SetupFromEnv()

histAnalysis.AddDataFile('fakescale_Data.root')
histAnalysis.SetBaseCut(cuts.cut('photon','nocut'))
histAnalysis.SetMCWeight('mcFactors/puWeight')

histAnalysis.MakeReweightHist('../slimmer/files/puWeight_28fb_2016.root', 'puWeight', 'npv', 35, 0, 35)
Exemplo n.º 14
0
    'cmva_jet1_pt > 60',
    'cmva_jet2_pt > 35',
    'n_lep_loose == 0',
    'cmva_jet1_cmva > 0.9432',
    'cmva_jet2_cmva > -0.5884',
    'cmva_hbb_m_reg_old < 160 && cmva_hbb_m_reg_old > 60',
    'cmva_hbb_pt_reg_old > 120',
    'dphi_met_trkmet < 0.5',
    'deltaPhi(metphi, cmva_hbb_phi) > 2.0',
    'cmva_dphi_uh > 2.0',
    'min_dphi_metj_hard > 0.5'
    ]

if len(sys.argv) == 1:
    for cut in loosecuts:
        cutflowMaker.AddCut(cut, cut)

    cutflowMaker.PrintCutflow()

else:
    cat = 'inclusive'
    for region in sys.argv[1:]:
        cutflowMaker.Reset()
        for cut in ['met_trigger == 1'] + cuts.cut(cat, region).split(' && '):
            cutflowMaker.AddCut(cut.strip(), cut)

        print '-' * 30
        print ' ' * 5, cat.upper(), region.upper()
        print '-' * 30
        cutflowMaker.PrintCutflow()
Exemplo n.º 15
0
#!/usr/bin/env python

from CrombieTools.AnalysisTools.HistAnalysis import *
from CrombieTools.LoadConfig import cuts
import os

SetupFromEnv()

histAnalysis.AddDataFile('test_Data.root')
histAnalysis.SetBaseCut(cuts.cut('example', 'control'))
histAnalysis.SetMCWeight('allWeights')
histAnalysis.SetSearchBy(histAnalysis.kLegendEntry)
histAnalysis.SetSignalName('MC1')
histAnalysis.SetNormalized(False)
histAnalysis.SetTreeName('test')

histAnalysis.MakeReweightHist('example_reweight.root', 'weight', 'example', 20, 0, 100)