Beispiel #1
0
 def createSusySampleCfg(m_stau=150, m_chi0=1):
     sname = 'SMS_TStauStau'
     return SampleCfg(
         name=sname + 'MStau{m_stau}MChi{m_chi0}'.format(m_stau=m_stau,
                                                         m_chi0=m_chi0),
         dir_name=sname,
         ana_dir=analysis_dir,
         tree_prod_name=tree_prod_name,
         xsec=get_xsec(m_stau),
         sumweights=normhist.GetBinContent(m_stau + 1, m_chi0 + 1, 1),
         is_signal=True,
         weight_expr=
         '(GenSusyMStau=={m_stau}. && GenSusyMNeutralino=={m_chi0})'.
         format(m_stau=m_stau, m_chi0=m_chi0))
Beispiel #2
0
def createSampleLists(analysis_dir='samples/',
                      channel='VV',
                      weight='',
                      signalSample='',
                      vJetsKFac=1.,
                      reweightVJets=False,
                      reweightTop=False):

    # settings and code to reweight V+jets samples (EW and QCD NLO corrections)
    # the following two k-factors are from samples_13TeV_RunIISpring16MiniAODv2.py
    wJetsKFac = 1.21
    dyJetsKFac = 1.23
    wJetsQCDCorrections = {}
    dyJetsQCDCorrections = {}
    # taken from http://cms.cern.ch/iCMS/jsp/db_notes/noteInfo.jsp?cmsnoteid=CMS%20AN-2015/186 (Table 4)
    wJetsQCDCorrections["WJetsToLNu_HT100to200"] = 1.459 / wJetsKFac
    wJetsQCDCorrections["WJetsToLNu_HT200to400"] = 1.434 / wJetsKFac
    wJetsQCDCorrections["WJetsToLNu_HT400to600"] = 1.532 / wJetsKFac
    wJetsQCDCorrections["WJetsToLNu_HT600to800"] = 1.004 / wJetsKFac
    wJetsQCDCorrections["WJetsToLNu_HT800to1200"] = 1.004 / wJetsKFac
    wJetsQCDCorrections["WJetsToLNu_HT1200to2500"] = 1.004 / wJetsKFac
    wJetsQCDCorrections["WJetsToLNu_HT2500toInf"] = 1.004 / wJetsKFac
    dyJetsQCDCorrections["DYJetsToLL_M50_HT100to200"] = 1.588 / dyJetsKFac
    dyJetsQCDCorrections["DYJetsToLL_M50_HT200to400"] = 1.438 / dyJetsKFac
    dyJetsQCDCorrections["DYJetsToLL_M50_HT400to600"] = 1.494 / dyJetsKFac
    dyJetsQCDCorrections["DYJetsToLL_M50_HT600toInf"] = 1.139 / dyJetsKFac

    # explicit list of samples:
    wjetsSampleNames = [
        "WJetsToLNu_HT1200to2500", "WJetsToLNu_HT2500toInf",
        "WJetsToLNu_HT400to600", "WJetsToLNu_HT600to800",
        "WJetsToLNu_HT800to1200", 'WJetsToLNu_HT100to200',
        'WJetsToLNu_HT200to400'
    ]
    dyjetsSampleNames = [
        'DYJetsToLL_M50_HT100to200', 'DYJetsToLL_M50_HT200to400',
        'DYJetsToLL_M50_HT400to600', 'DYJetsToLL_M50_HT600toInf'
    ]
    ttjetsSampleNames = ["TT_pow_ext3"]
    qcdSampleNames = [
        "QCD_HT1000to1500", "QCD_HT1500to2000", "QCD_HT2000toInf",
        "QCD_HT500to700", "QCD_HT700to1000"
    ]
    vvSampleNames = ['WWTo1L1Nu2Q', 'WZTo1L1Nu2Q']
    singleTopSampleNames = [
        'TToLeptons_tch_powheg', 'TBarToLeptons_tch_powheg', 'TToLeptons_sch',
        'TBar_tWch', 'T_tWch'
    ]
    jj_SampleNames = qcdSampleNames
    lnujj_SampleNames = ttjetsSampleNames + wjetsSampleNames + vvSampleNames + qcdSampleNames + dyjetsSampleNames + singleTopSampleNames
    # cuts to split ttbar sample according to W decay
    ttjetsWCut = '(lnujj_l2_mergedVTruth==1&&lnujj_l2_nearestBDRTruth>0.8)'
    ttjetsNonWCut = '(!(lnujj_l2_mergedVTruth==1&&lnujj_l2_nearestBDRTruth>0.8))'
    # add ttbar pT reweighting
    if reweightTop:
        ttjetsWCut += '*truth_genTop_weight'
        ttjetsNonWCut += '*truth_genTop_weight'

    tree_prod_name = ''

    if (channel == "WV"):
        channelSampleNames = lnujj_SampleNames
    else:
        channelSampleNames = jj_SampleNames
    samples_essential = []

    if "/sVJetsReweighting_cc.so" not in gSystem.GetLibraries():
        ROOT.gROOT.ProcessLine(
            ".L %s/src/CMGTools/VVResonances/python/plotting/VJetsReweighting.cc+"
            % os.environ['CMSSW_BASE'])
    from ROOT import getDYWeight, getWWeight

    # add QCD, DY+jets, W+jets, DiBosons and SingleTop samples, but not those with _ext, since they are merged with the others
    for sample in QCDHT + DYJetsM50HT + WJetsToLNuHT + DiBosons + SingleTop:
        vJetsWeight = str(vJetsKFac)
        if sample.name in channelSampleNames:
            if (sample in DYJetsM50HT) and reweightVJets:
                vJetsWeight = 'getDYWeight(truth_genBoson_pt) * {}'.format(
                    dyJetsQCDCorrections[sample.name])
            elif (sample in WJetsToLNuHT) and reweightVJets:
                vJetsWeight = 'getWWeight(truth_genBoson_pt) * {}'.format(
                    wJetsQCDCorrections[sample.name])
            samples_essential.append(
                SampleCfg(name=sample.name,
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=('*'.join([weight, vJetsWeight]))))

    # TTJets sample
    for sample in [TT_pow]:
        if sample.name in channelSampleNames:
            # print "Adding", sample.name, sample.xSection, sample.nGenEvents, weight
            samples_essential.append(
                SampleCfg(name=sample.name + '_W',
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=('*'.join([weight, ttjetsWCut]))))
            samples_essential.append(
                SampleCfg(name=sample.name + '_nonW',
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=('*'.join([weight, ttjetsNonWCut]))))

    # signal sample (set signal xsec to 5 pb)
    samples_signal = []
    if (signalSample):
        for sample in signalSamples:
            if sample.name == signalSample:
                samples_signal.append(
                    SampleCfg(name=sample.name,
                              dir_name=sample.name,
                              ana_dir=analysis_dir,
                              tree_prod_name=tree_prod_name,
                              xsec=5.,
                              sumweights=sample.nGenEvents,
                              weight_expr=('*'.join([weight])),
                              is_signal=True))

    samples_data = []
    if channel == 'WV':
        samples_data = [
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016B_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016C_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016D_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016B_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016C_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016D_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016B_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016C_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016D_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]
    else:
        samples_data = [
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2016B_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2016C_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2016D_PromptReco_v2',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]

    # samples_WH = []
    # mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250', 'HiggsSUSYBB300', 'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB900', 'HiggsSUSYBB1000', 'HiggsSUSYBB1200', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2600', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
    #               'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG140', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800', 'HiggsSUSYGG900', 'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500', 'HiggsSUSYGG1600', 'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # HiggsSUSYBB800, HiggsSUSYBB1400, HiggsSUSYGG350
    # for name in mssm_names:
    #     samples_WH.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
    #                                   ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)

    samples_mc = samples_essential + samples_signal
    samples = samples_essential + samples_data + samples_signal
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    weighted_list = []

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample)

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #3
0
def createSampleLists(analysis_dir='/afs/cern.ch/user/s/steggema/work/public/mt/NewProd',
                      channel='mt',
                      mode='sm',
                      ztt_cut='(l2_gen_match == 5)*getDYWeight(genboson_mass, genboson_pt)', zl_cut='(l2_gen_match < 5)*getDYWeight(genboson_mass, genboson_pt)',
                      zj_cut='(l2_gen_match == 6)*getDYWeight(genboson_mass, genboson_pt)',
                      data2016G=False,
                      signal_scale=1.):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly
    if channel == 'mt':
        tree_prod_name = 'H2TauTauTreeProducerTauMu'
    elif channel == 'et':
        tree_prod_name = 'H2TauTauTreeProducerTauEle'
    elif channel == 'mm':
        tree_prod_name = 'H2TauTauTreeProducerMuMu'
    elif channel == 'tt':
        tree_prod_name = 'H2TauTauTreeProducerTauTau'
    elif channel == 'em':
        tree_prod_name = 'H2TauTauTreeProducerMuEle'
    elif channel == 'tau_fr':
        tree_prod_name = 'TauFRTreeProducer'

    DYJetsToLL_M50_LO.nGenEvents = 1000.
    # WJetsToLNu_LO.nGenEvents = 1000.

    samples_essential = [
        # SampleCfg(name='ZTTM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=ztt_cut),
        # SampleCfg(name='ZLM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                  # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=zl_cut),
        # SampleCfg(name='ZJM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=zj_cut),
    ]
    if useDYWeight:
        samples_essential += [
            SampleCfg(name='ZTT', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut+dy_exp),
            SampleCfg(name='ZL', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zl_cut+dy_exp),
            SampleCfg(name='ZJ', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut+dy_exp),
            
        ]
    else:
        if not splitDY:
            samples_essential += [
                SampleCfg(name='ZTT', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut),
                SampleCfg(name='ZL', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zl_cut),
                SampleCfg(name='ZJ', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut),
            ]
        else:
            samples_essential += [
                SampleCfg(name='ZTT', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut),
                SampleCfg(name='Zl0jet', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr='('+zl_cut+'*(jet1_genjet_pt<8.))'),
                SampleCfg(name='Zl1jet', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr='('+zl_cut+'*(jet1_genjet_pt>8. && jet2_genjet_pt<8.))'),
                SampleCfg(name='Zl2jet', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr='('+zl_cut+'*(jet1_genjet_pt>8. && jet2_genjet_pt>8.))'),
                SampleCfg(name='ZJ', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut),
            ]
        # SampleCfg(name='ZTTM150', dir_name='DYJetsToTauTau_M150_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut+dy_exp),
        # SampleCfg(name='ZLM150', dir_name='DYJetsToTauTau_M150_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zl_cut+dy_exp),
        # SampleCfg(name='ZJM150', dir_name='DYJetsToTauTau_M150_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut+dy_exp),
    samples_essential += [
        # SampleCfg(name='W', dir_name='WJetsToLNu_LO' if channel != 'mm' else 'WJetsToLNu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
        #           xsec=WJetsToLNu_LO.xSection, sumweights=WJetsToLNu_LO.nGenEvents, weight_expr=w_exp if channel != 'tau_fr' else '(geninfo_htgen<100.)'),
        SampleCfg(name='TT', dir_name='TT_pow_ext3', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow_ext.xSection, sumweights=TT_pow_ext.nGenEvents),
        SampleCfg(name='T_tWch', dir_name='T_tWch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=T_tWch.xSection, sumweights=T_tWch.nGenEvents),
        SampleCfg(name='TBar_tWch', dir_name='TBar_tWch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBar_tWch.xSection, sumweights=TBar_tWch.nGenEvents),
        # SampleCfg(name='HiggsGGH125', dir_name='HiggsGGH125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsGGH125.xSection, sumweights=HiggsGGH125.nGenEvents),
        # SampleCfg(name='HiggsVBF125', dir_name='HiggsVBF125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsVBF125.xSection, sumweights=HiggsVBF125.nGenEvents),
        # SampleCfg(name='QCD', dir_name='QCD_Mu15', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=QCD_Mu15.xSection)
    ]

    if channel in ['tau_fr']:
        k_factor = '1.'
        samples_essential += [
            # SampleCfg(name='WJetsToLNu_HT100to200', dir_name='WJetsToLNu_HT100to200', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT100to200.xSection, sumweights=WJetsToLNu_HT100to200.nGenEvents, weight_expr=k_factor),
            # SampleCfg(name='WJetsToLNu_HT200to400', dir_name='WJetsToLNu_HT200to400', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT200to400.xSection, sumweights=WJetsToLNu_HT200to400.nGenEvents, weight_expr=k_factor),
            # SampleCfg(name='WJetsToLNu_HT400to600', dir_name='WJetsToLNu_HT400to600', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT400to600.xSection, sumweights=WJetsToLNu_HT400to600.nGenEvents, weight_expr=k_factor),
            # SampleCfg(name='WJetsToLNu_HT600toInf', dir_name='WJetsToLNu_HT600toInf', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT600toInf.xSection, sumweights=WJetsToLNu_HT600toInf.nGenEvents, weight_expr=k_factor),
        ]

    if useDYWeight and channel not in ['mm', 'tau_fr']:
        for sample in DYNJets:
            n_jet_name = str(sample.name[sample.name.find('Jets')-1])+'Jets'
            print 'WARNING - DY - using n(gen events)', DYJetsToLL_M50_LO.nevents[0], 'for DY', n_jet_name
            samples_essential += [
                SampleCfg(name='ZTT'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=DYJetsToLL_M50_LO.nevents[0], weight_expr=ztt_cut+dy_exp),
                SampleCfg(name='ZL'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=DYJetsToLL_M50_LO.nevents[0], weight_expr=zl_cut+dy_exp),
                SampleCfg(name='ZJ'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=DYJetsToLL_M50_LO.nevents[0], weight_expr=zj_cut+dy_exp),
            ]
    for sample in WNJets:
        n_jet_name = str(sample.name[sample.name.find('Jets')-1])+'Jets'
        # print 'WARNING - W - using n(gen events)', WJetsToLNu_LO.nevents[0], 'for W n(jets)', n_jet_name, 'xsec', sample.xSection
        samples_essential += [
            SampleCfg(name='W'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection) #, sumweights=WJetsToLNu_LO.nevents[0]) #, weight_expr=w_exp)
            ]

    samples_data = []
    if data2016G and channel in ['mt', 'mm', 'tau_fr']:
         samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016G_PromptReco_v1', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True)
        ]
    elif channel in ['mt', 'mm', 'tau_fr']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016C_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016D_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['et']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleElectron_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['tt']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='Tau_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='Tau_Run2016C_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='Tau_Run2016D_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['em']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='MuonEG_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='MuonEG_Run2016C_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='MuonEG_Run2016D_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]

    samples_additional = [
        # SampleCfg(name='TToLeptons_tch', dir_name='TToLeptons_tch_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_amcatnlo.xSection, sumweights=TToLeptons_tch_amcatnlo.nGenEvents),
        SampleCfg(name='TToLeptons_tch_powheg', dir_name='TToLeptons_tch_powheg', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_powheg.xSection, sumweights=TToLeptons_tch_powheg.nGenEvents),
        SampleCfg(name='TBarToLeptons_tch_powheg', dir_name='TBarToLeptons_tch_powheg', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBarToLeptons_tch_powheg.xSection, sumweights=TBarToLeptons_tch_powheg.nGenEvents),
        # SampleCfg(name='TToLeptons_tch_powheg', dir_name='TToLeptons_tch_powheg', ana_dir=analysis_dir,
        #           tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_powheg.xSection, sumweights=TToLeptons_tch_powheg.nGenEvents),
    ]

    samples_additional += [
        SampleCfg(name='ZZTo4L', dir_name='ZZTo4L', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZTo4L.xSection, sumweights=ZZTo4L.nGenEvents),
        SampleCfg(name='ZZTo2L2Q', dir_name='ZZTo2L2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZTo2L2Q.xSection, sumweights=ZZTo2L2Q.nGenEvents),
        # SampleCfg(name='WZTo3L', dir_name='WZTo3LNu_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo3LNu_amcatnlo.xSection, sumweights=WZTo3LNu_amcatnlo.nGenEvents),
        SampleCfg(name='WZTo2L2Q', dir_name='WZTo2L2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo2L2Q.xSection, sumweights=WZTo2L2Q.nGenEvents),
        SampleCfg(name='WZTo1L3Nu', dir_name='WZTo1L3Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo1L3Nu.xSection, sumweights=WZTo1L3Nu.nGenEvents),
        SampleCfg(name='WZTo1L1Nu2Q', dir_name='WZTo1L1Nu2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo1L1Nu2Q.xSection, sumweights=WZTo1L1Nu2Q.nGenEvents),
        SampleCfg(name='VVTo2L2Nu', dir_name='VVTo2L2Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=VVTo2L2Nu.xSection, sumweights=VVTo2L2Nu.nGenEvents),
        SampleCfg(name='WWTo1L1Nu2Q', dir_name='WWTo1L1Nu2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WWTo1L1Nu2Q.xSection, sumweights=WWTo1L1Nu2Q.nGenEvents),
    ]

    samples_mssm = []
    # mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250', 'HiggsSUSYBB300', 'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB900', 'HiggsSUSYBB1000', 'HiggsSUSYBB1200', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2600', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
                  # 'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG140', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800', 'HiggsSUSYGG900', 'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500', 'HiggsSUSYGG1600', 'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # HiggsSUSYBB800, HiggsSUSYBB1400, HiggsSUSYGG350
    mssm_names = ['HiggsSUSYGG160', 'HiggsSUSYBB500', 'HiggsSUSYBB1000',]
    for name in mssm_names:
        samples_mssm.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
                                      ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)
        # SampleCfg(name='HiggsSUSYGG200', dir_name='HiggsSUSYGG200', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG500', dir_name='HiggsSUSYGG500', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG1000', dir_name='HiggsSUSYGG1000', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG1500', dir_name='HiggsSUSYGG1500', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
    # ]

    samples_susy = []
    if mode == 'susy':
        
        normfile = ROOT.TFile('/data1/steggema/tt/230816/DiTauNewMC/SMS_TStauStau/ttHhistoCounterAnalyzer/sumhist.root')
        normhist = normfile.Get('SumGenWeightsSMS')

        def createSusySampleCfg(m_stau=150, m_chi0=1):
            sname = 'SMS_TStauStau'
            return SampleCfg(name=sname+'MStau{m_stau}MChi{m_chi0}'.format(m_stau=m_stau, m_chi0=m_chi0), dir_name=sname, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=get_xsec(m_stau), sumweights=normhist.GetBinContent(m_stau+1, m_chi0+1, 1), is_signal=True, weight_expr='(GenSusyMStau=={m_stau}. && GenSusyMNeutralino=={m_chi0})'.format(m_stau=m_stau, m_chi0=m_chi0))

        samples_susy.append(createSusySampleCfg(100, 1))
        samples_susy.append(createSusySampleCfg(200, 1))
        samples_susy.append(createSusySampleCfg(150, 1))
        samples_susy.append(createSusySampleCfg(150, 10))
        samples_susy.append(createSusySampleCfg(150, 20))
        samples_susy.append(createSusySampleCfg(150, 50))
        samples_susy.append(createSusySampleCfg(150, 100))


    if mode == 'mssm':
        samples_additional += samples_mssm
    if mode == 'susy':
        samples_additional += samples_susy

    samples_mc = samples_essential + samples_additional 

    samples = samples_essential + samples_additional + samples_data
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    # weighted_list = ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']
    weighted_list = []
    weighted_list += [s.name for s in samples_susy]
    if useDYWeight:
        weighted_list += ['ZTT', 'ZTT1Jets', 'ZTT2Jets', 'ZTT3Jets', 'ZTT4Jets',
                          'ZJ', 'ZJ1Jets', 'ZJ2Jets', 'ZJ3Jets', 'ZJ4Jets',
                          'ZL', 'ZL1Jets', 'ZL2Jets', 'ZL3Jets', 'ZL4Jets',
                          'ZTTM150', 'ZJM150', 'ZLM150']

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample, 'MCWeighter' if channel not in ['tau_fr'] else 'SkimAnalyzerCount')

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    for sample in all_samples:
        if sample.is_signal:
            sample.scale = sample.scale * signal_scale

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #4
0
def createSampleLists(analysis_dir='samples/', channel='VV', weight=''):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly

    tree_prod_name = ''

    samples_essential = []
    # add QCD samples, but not those with _ext, since they are not produced
    for sample in QCDHT:
        if not (sample.name.find("_ext") >= 0):
            samples_essential.append(
                SampleCfg(name=sample.name,
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=weight))

    # TTJets sample
    samples_essential.append(
        SampleCfg(name=TTJets.name,
                  dir_name=TTJets.name,
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TTJets.xSection,
                  sumweights=TTJets.nGenEvents,
                  weight_expr=weight))

    # DY+jets samples, but not those with _ext, since they are not produced
    for dySample in DYJetsM50HT:
        if not (sample.name.find("_ext") >= 0):
            samples_essential.append(
                SampleCfg(name=dySample.name,
                          dir_name=dySample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=dySample.xSection,
                          sumweights=dySample.nGenEvents,
                          weight_expr=weight))

    # W+jets samples, but not those with _ext, since they are not produced
    for sample in WJetsToLNuHT:
        if not (sample.name.find("_ext") >= 0):
            samples_essential.append(
                SampleCfg(name=sample.name,
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=weight))

    # DiBosons samples
    for sample in DiBosons:
        if not (sample.name.find("NuNu") >= 0):
            samples_essential.append(
                SampleCfg(name=sample.name,
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=weight))

    # SingleTop samples
    for sample in SingleTop:
        if not (sample.name.find("tZq_ll") >= 0):
            samples_essential.append(
                SampleCfg(name=sample.name,
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=weight))

    samples_data = []
    # if channel in ['VV']:
    samples_data = [
        SampleCfg(name='data_obs',
                  dir_name='JetHT_Run2016B_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='JetHT_Run2016C_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='JetHT_Run2016D_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='SingleMuon_Run2016B_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='SingleMuon_Run2016C_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='SingleMuon_Run2016D_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='SingleElectron_Run2016B_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='SingleElectron_Run2016C_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='SingleElectron_Run2016D_PromptReco_v2',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
    ]

    # samples_WH = []
    # mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250', 'HiggsSUSYBB300', 'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB900', 'HiggsSUSYBB1000', 'HiggsSUSYBB1200', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2600', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
    #               'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG140', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800', 'HiggsSUSYGG900', 'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500', 'HiggsSUSYGG1600', 'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # HiggsSUSYBB800, HiggsSUSYBB1400, HiggsSUSYGG350
    # for name in mssm_names:
    #     samples_WH.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
    #                                   ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)

    samples_mc = samples_essential  # + samples_WH
    samples = samples_essential + samples_data
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    weighted_list = []

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample)

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #5
0
def createSampleLists(analysis_dir='/afs/cern.ch/user/s/steggema/work/public/mt/NewProd',
                      channel='mt',
                      mode='sm',
                      ztt_cut='(l2_gen_match == 5)', zl_cut='(l2_gen_match < 5)',
                      zj_cut='(l2_gen_match == 6)',
                      data2016G=False,
                      signal_scale=1.,
                      no_data=False):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly
    if channel == 'mt':
        tree_prod_name = 'H2TauTauTreeProducerTauMu'
    elif channel == 'et':
        tree_prod_name = 'H2TauTauTreeProducerTauEle'
    elif channel == 'mm':
        tree_prod_name = 'H2TauTauTreeProducerMuMu'
    elif channel == 'tt':
        tree_prod_name = 'H2TauTauTreeProducerTauTau'
    elif channel == 'em':
        tree_prod_name = 'H2TauTauTreeProducerMuEle'
    elif channel == 'tau_fr':
        tree_prod_name = 'TauFRTreeProducer'

    samples_essential = [
        # SampleCfg(name='ZTTM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=ztt_cut),
        # SampleCfg(name='ZLM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                  # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=zl_cut),
        # SampleCfg(name='ZJM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=zj_cut),
    ]
    if splitDY:
        for sample in [DYJetsToLL_M50_LO_ext2, DYJetsToLL_M50_LO]:
            samples_essential += [
                SampleCfg(name='ZTT', dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., weight_expr=ztt_cut+dy_exp),
                SampleCfg(name='ZL', dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=1., sumweights=1., weight_expr=zl_cut+dy_exp),
                SampleCfg(name='ZJ', dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                          xsec=1., sumweights=1., weight_expr=zj_cut+dy_exp),
            ]
        
    else:
        samples_essential += [
            SampleCfg(name='ZTT', dir_name=DYJetsToLL_M50_LO_ext2.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO_ext2.xSection, sumweights=DYJetsToLL_M50_LO_ext2.nGenEvents, weight_expr=ztt_cut),
            SampleCfg(name='ZL', dir_name=DYJetsToLL_M50_LO_ext2.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO_ext2.xSection, sumweights=DYJetsToLL_M50_LO_ext2.nGenEvents, weight_expr=zl_cut),
            SampleCfg(name='ZJ', dir_name=DYJetsToLL_M50_LO_ext2.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO_ext2.xSection, sumweights=DYJetsToLL_M50_LO_ext2.nGenEvents, weight_expr=zj_cut),
            ]

    if channel == 'tt':
        samples_essential += [
            # SampleCfg(name='TTT', dir_name='TT_pow', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow.xSection, sumweights=TT_pow.nGenEvents, weight_expr='l1_gen_match==5 && l2_gen_match==5'),
            # SampleCfg(name='TTJ', dir_name='TT_pow', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow.xSection, sumweights=TT_pow.nGenEvents, weight_expr='!(l1_gen_match==5 && l2_gen_match==5)'),
            SampleCfg(name='TT', dir_name='TT_pow', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow.xSection, sumweights=TT_pow.nGenEvents),
        ]
    else:
        samples_essential += [
            SampleCfg(name='TT', dir_name='TT_pow', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow.xSection, sumweights=TT_pow.nGenEvents),
        ]

    samples_essential += [
            SampleCfg(name='T_tWch', dir_name='T_tWch_ext', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=T_tWch.xSection, sumweights=T_tWch.nGenEvents),
            SampleCfg(name='TBar_tWch', dir_name='TBar_tWch_ext', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBar_tWch.xSection, sumweights=TBar_tWch.nGenEvents),
            # SampleCfg(name='HiggsGGH125', dir_name='HiggsGGH125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsGGH125.xSection, sumweights=HiggsGGH125.nGenEvents),
            # SampleCfg(name='HiggsVBF125', dir_name='HiggsVBF125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsVBF125.xSection, sumweights=HiggsVBF125.nGenEvents),
            # SampleCfg(name='QCD', dir_name='QCD_Mu15', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=QCD_Mu15.xSection)
        ]

    if splitDY and channel not in ['mm', 'tau_fr']:
        for sample in DYNJets:
            n_jet_name = str(sample.name[sample.name.find('Jets')-1])+'Jets'
            samples_essential += [
                SampleCfg(name='ZTT'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., weight_expr=ztt_cut+dy_exp),
                SampleCfg(name='ZL'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., weight_expr=zl_cut+dy_exp),
                SampleCfg(name='ZJ'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., weight_expr=zj_cut+dy_exp),
            ]
    for sample in WNJets:
        n_jet_name = str(sample.name[sample.name.find('Jets')-1])+'Jets'
        # print 'WARNING - W - using n(gen events)', WJetsToLNu_LO.nevents[0], 'for W n(jets)', n_jet_name, 'xsec', sample.xSection
        samples_essential += [
            SampleCfg(name='W'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection) #, sumweights=WJetsToLNu_LO.nevents[0]) #, weight_expr=w_exp)
            ]

    samples_data = []
    if data2016G and channel in ['mt', 'mm', 'tau_fr']:
         samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016G_PromptReco_v1', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True)
        ]
    elif channel in ['mt', 'mm', 'tau_fr']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016C_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016D_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['et']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleElectron_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['tt']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name=mc_comp.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True) for mc_comp in data_tau
        ]
    elif channel in ['em']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='MuonEG_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='MuonEG_Run2016C_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
            SampleCfg(name='data_obs', dir_name='MuonEG_Run2016D_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]

    if no_data:
        samples_data = []

    samples_additional = [
        SampleCfg(name='TToLeptons_tch_powheg', dir_name=T_tch_powheg.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=T_tch_powheg.xSection, sumweights=T_tch_powheg.nGenEvents),
        SampleCfg(name='TBarToLeptons_tch_powheg', dir_name=TBar_tch_powheg.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBar_tch_powheg.xSection, sumweights=TBar_tch_powheg.nGenEvents),
    ]

    samples_additional += [
        SampleCfg(name='ZZTo4L', dir_name='ZZTo4L', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZTo4L.xSection, sumweights=ZZTo4L.nGenEvents),
        SampleCfg(name='ZZTo2L2Q', dir_name='ZZTo2L2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZTo2L2Q.xSection, sumweights=ZZTo2L2Q.nGenEvents),
        # SampleCfg(name='WZTo3L', dir_name='WZTo3LNu_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo3LNu_amcatnlo.xSection, sumweights=WZTo3LNu_amcatnlo.nGenEvents),
        SampleCfg(name='WZTo2L2Q', dir_name='WZTo2L2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo2L2Q.xSection, sumweights=WZTo2L2Q.nGenEvents),
        SampleCfg(name='WZTo1L3Nu', dir_name='WZTo1L3Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo1L3Nu.xSection, sumweights=WZTo1L3Nu.nGenEvents),
        SampleCfg(name='WZTo1L1Nu2Q', dir_name='WZTo1L1Nu2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo1L1Nu2Q.xSection, sumweights=WZTo1L1Nu2Q.nGenEvents),
        SampleCfg(name='VVTo2L2Nu', dir_name='VVTo2L2Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=VVTo2L2Nu.xSection, sumweights=VVTo2L2Nu.nGenEvents),
        SampleCfg(name='WWTo1L1Nu2Q', dir_name='WWTo1L1Nu2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WWTo1L1Nu2Q.xSection, sumweights=WWTo1L1Nu2Q.nGenEvents),
    ]

    samples_sm = [
        SampleCfg(name='HiggsGGH125', dir_name='HiggsGGH125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsGGH125.xSection, sumweights=HiggsGGH125.nGenEvents, is_signal=True),
        SampleCfg(name='HiggsVBF125', dir_name='HiggsVBF125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsVBF125.xSection, sumweights=HiggsVBF125.nGenEvents, is_signal=True),
    ]

    samples_mssm = []
    # '80', '90',
    masses_bbh = [ '100', '110', '120', '130', '140', '160', '180', '200', '250',  '350', '400', '450',  '500', '600', '700', '800', '900', '1000',  '1400', '1600', '1800', '2000', '2300', '2900', '3200']
    # '80', '90',
    masses_ggh = ['100', '110', '120', '130', '160', '180', '200', '250', '350', '400', '450', '500', '600', '700', '800',  '1000', '1200', '1400', '1800', '2000', '2300', '2600', '2900', '3200']

    # mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250',  'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB800', 'HiggsSUSYBB900', 'HiggsSUSYBB1000',  'HiggsSUSYBB1400', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
    #               'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG350', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800',  'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500',  'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # 'HiggsSUSYBB300','HiggsSUSYBB1200', 'HiggsSUSYBB2600', 'HiggsSUSYGG140', 'HiggsSUSYGG900','HiggsSUSYGG1600',
    # # mssm_names = ['HiggsSUSYGG160', 'HiggsSUSYGG500', 'HiggsSUSYGG1000',
    # #               'HiggsSUSYBB160', 'HiggsSUSYBB500', 'HiggsSUSYBB1000',]

    limits_ichep_ggh = {'2900': 0.0064239501953125, '450': 0.12127685546875, '700': 0.0381317138671875, '130': 10.5439453125, '110': 21.0205078125, '250': 0.79638671875, '2300': 0.007214355282485485, '180': 2.4345703125, '400': 0.17047119140625, '1400': 0.010340881533920765, '500': 0.089935302734375, '200': 1.708984375, '140': 7.3095703125, '120': 15.7705078125, '100': 24.57275390625, '160': 3.9550781249999996, '900': 0.02440795861184597, '1800': 0.008679199032485485, '1600': 0.009762573055922985, '3200': 0.0063995360396802425, '2000': 0.008056640625, '350': 0.2442626953125, '800': 0.0279693603515625, '1000': 0.01924438402056694, '1200':0.013682556338608265, '2600':0.0067382813431322575}

    limits_ichep_ggh['300'] = 0.5
    limits_ichep_ggh['600'] = 0.06
    limits_ichep_ggh['1500'] = 0.01

    limits_ichep_bbh = {'2900': 0.005267334170639515, '450': 0.069732666015625, '700': 0.030960083007812497, '130': 4.880859375, '110': 10.3125, '250': 0.3885498046875, '2300': 0.0059265135787427425, '180': 1.17919921875, '400': 0.095672607421875, '1400': 0.01087188720703125, '500': 0.0551605224609375, '200': 0.80517578125, '140': 3.818359375, '120': 6.77490234375, '100': 15.25390625, '160': 1.8818359375, '900': 0.02145080640912056, '1800': 0.007534789852797985, '1600': 0.00846252404153347, '3200': 0.0050369263626635075, '2000': 0.0066925049759447575, '350': 0.13861083984375, '800': 0.025848388671875, '1000': 0.01756439171731472}

    limits_ichep_bbh['600'] = 0.045
    limits_ichep_bbh['1500'] = 0.0095


    for mass in masses_bbh:
        samples_mssm.append(SampleCfg(name='bbH'+mass, dir_name='HiggsSUSYBB'+mass, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=limits_ichep_bbh[mass], sumweights=1., is_signal=True))

    for mass in masses_ggh:
        if mass not in limits_ichep_ggh: import pdb; pdb.set_trace()
        samples_mssm.append(SampleCfg(name='ggH'+mass, dir_name='HiggsSUSYGG'+mass, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=limits_ichep_ggh[mass], sumweights=1., is_signal=True))

    # for name in mssm_names:
    #     samples_mssm.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
    #                                   ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)
        
        # SampleCfg(name='HiggsSUSYGG200', dir_name='HiggsSUSYGG200', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG500', dir_name='HiggsSUSYGG500', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG1000', dir_name='HiggsSUSYGG1000', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG1500', dir_name='HiggsSUSYGG1500', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
    # ]

    samples_susy = []
    if mode == 'susy':
        
        # normfile = ROOT.TFile(' /afs/cern.ch/work/s/steggema/public/tt/100417/SMS_TChipmStauSnu/ttHhistoCounterAnalyzer/sumhist.root')
        normfile = ROOT.TFile(' /afs/cern.ch/work/s/steggema/public/tt/270617/sms_sys/SMS_TChipmStauSnu//H2TauTauTreeProducerTauTau/tree.root')
        normhist = normfile.Get('SumGenWeightsSMS')

        from CMGTools.H2TauTau.proto.plotter.categories_TauTau import inc_trigger
        def createSusySampleCfg(m_stau=150, m_chi0=1):

            sname = 'SMS_TChipmStauSnu'
            print "setting sum of weights to", normhist.GetBinContent(m_stau+1, m_chi0+1, 1), 'for', sname+'MStau{m_stau}MChi{m_chi0}'.format(m_stau=m_stau, m_chi0=m_chi0)
            return SampleCfg(name=sname+'MStau{m_stau}MChi{m_chi0}'.format(m_stau=m_stau, m_chi0=m_chi0), dir_name=sname, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=get_xsec(m_stau), sumweights=normhist.GetBinContent(m_stau+1, m_chi0+1, 1), is_signal=True, weight_expr='(GenSusyMChargino=={m_stau}. && GenSusyMNeutralino=={m_chi0})'.format(m_stau=m_stau, m_chi0=m_chi0),
                cut_replace_func=lambda s : s.replace(inc_trigger.cutstr, '1.'))

        # # the following is good for staus
        # samples_susy.append(createSusySampleCfg(100, 1))
        # samples_susy.append(createSusySampleCfg(200, 1))
        # samples_susy.append(createSusySampleCfg(150, 1))
        # samples_susy.append(createSusySampleCfg(150, 10))
        # samples_susy.append(createSusySampleCfg(150, 20))
        # samples_susy.append(createSusySampleCfg(150, 50))
        # samples_susy.append(createSusySampleCfg(150, 100))

        # samples_susy.append(createSusySampleCfg(100, 1))
        # samples_susy.append(createSusySampleCfg(200, 1))
        # samples_susy.append(createSusySampleCfg(150, 1))
        samples_susy.append(createSusySampleCfg(150, 25))
        samples_susy.append(createSusySampleCfg(300, 100))
        samples_susy.append(createSusySampleCfg(500, 1))
        samples_susy.append(createSusySampleCfg(600, 1))

    if mode in ['sm', 'mva']:
        samples_additional += samples_sm
    if mode == 'mssm':
        samples_additional += samples_mssm
    if mode == 'susy':
        samples_additional += samples_susy

    samples_mc = samples_essential + samples_additional 

    samples = samples_essential + samples_additional + samples_data
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    # weighted_list = ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']
    weighted_list = []
    weighted_list += [s.name for s in samples_susy]
    if splitDY:
        weighted_list += ['ZTT', 'ZTT1Jets', 'ZTT2Jets', 'ZTT3Jets', 'ZTT4Jets',
                          'ZJ', 'ZJ1Jets', 'ZJ2Jets', 'ZJ3Jets', 'ZJ4Jets',
                          'ZL', 'ZL1Jets', 'ZL2Jets', 'ZL3Jets', 'ZL4Jets',
                          'ZTTM150', 'ZJM150', 'ZLM150']

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample, 'MCWeighter' if channel not in ['tau_fr'] else 'SkimAnalyzerCount')
            print 'Set sum weights for sample', sample.name, 'to', sample.sumweights

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    for sample in all_samples:
        if sample.is_signal:
            sample.scale = sample.scale * signal_scale

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #6
0
        def createSusySampleCfg(m_stau=150, m_chi0=1):

            sname = 'SMS_TChipmStauSnu'
            print "setting sum of weights to", normhist.GetBinContent(m_stau+1, m_chi0+1, 1), 'for', sname+'MStau{m_stau}MChi{m_chi0}'.format(m_stau=m_stau, m_chi0=m_chi0)
            return SampleCfg(name=sname+'MStau{m_stau}MChi{m_chi0}'.format(m_stau=m_stau, m_chi0=m_chi0), dir_name=sname, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=get_xsec(m_stau), sumweights=normhist.GetBinContent(m_stau+1, m_chi0+1, 1), is_signal=True, weight_expr='(GenSusyMChargino=={m_stau}. && GenSusyMNeutralino=={m_chi0})'.format(m_stau=m_stau, m_chi0=m_chi0),
                cut_replace_func=lambda s : s.replace(inc_trigger.cutstr, '1.'))
Beispiel #7
0
def createSampleLists(
        analysis_dir='/afs/cern.ch/user/s/steggema/work/public/mt/NewProd',
        channel='mt',
        ztt_cut='(l2_gen_match == 5)',
        zl_cut='(l2_gen_match < 5)',
        zj_cut='(l2_gen_match == 6)'):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly
    if channel == 'mt':
        tree_prod_name = 'H2TauTauTreeProducerTauMu'
    elif channel == 'et':
        tree_prod_name = 'H2TauTauTreeProducerTauEle'
    elif channel == 'mm':
        tree_prod_name = 'H2TauTauTreeProducerMuMu'
    elif channel == 'tt':
        tree_prod_name = 'H2TauTauTreeProducerTauTau'
    elif channel == 'em':
        tree_prod_name = 'H2TauTauTreeProducerMuEle'

    samples_essential = [
        SampleCfg(name='ZTT',
                  dir_name='DYJetsToLL_M50_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=DYJetsToLL_M50_LO.xSection,
                  sumweights=DYJetsToLL_M50_LO.nGenEvents,
                  weight_expr=ztt_cut),
        SampleCfg(name='ZL',
                  dir_name='DYJetsToLL_M50_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=DYJetsToLL_M50_LO.xSection,
                  sumweights=DYJetsToLL_M50_LO.nGenEvents,
                  weight_expr=zl_cut),
        SampleCfg(name='ZJ',
                  dir_name='DYJetsToLL_M50_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=DYJetsToLL_M50_LO.xSection,
                  sumweights=DYJetsToLL_M50_LO.nGenEvents,
                  weight_expr=zj_cut),
        SampleCfg(name='W',
                  dir_name='WJetsToLNu',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WJetsToLNu.xSection,
                  sumweights=WJetsToLNu.nGenEvents,
                  weight_expr='1.'),
        # SampleCfg(name='W', dir_name='WJetsToLNu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_LO.xSection, sumweights=WJetsToLNu_LO.nGenEvents, weight_expr='1.'),
        SampleCfg(name='TT',
                  dir_name='TT_pow_ext',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TT_pow_ext.xSection,
                  sumweights=TT_pow_ext.nGenEvents),
        SampleCfg(name='T_tWch',
                  dir_name='T_tWch',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=T_tWch.xSection,
                  sumweights=T_tWch.nGenEvents),
        SampleCfg(name='TBar_tWch',
                  dir_name='TBar_tWch',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TBar_tWch.xSection,
                  sumweights=TBar_tWch.nGenEvents),
        # SampleCfg(name='QCD', dir_name='QCD_Mu15', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=QCD_Mu15.xSection)
    ]

    for sample in DYNJets:
        n_jet_name = str(sample.name[sample.name.find('Jets') - 1]) + 'Jets'
        print 'WARNING - DY - using n(gen events)', DYJetsToLL_M50_LO.nevents[
            0]
        samples_essential += [
            SampleCfg(name='ZTT' + n_jet_name,
                      dir_name=sample.name,
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=sample.xSection,
                      sumweights=DYJetsToLL_M50_LO.nevents[0],
                      weight_expr=ztt_cut),
            SampleCfg(name='ZL' + n_jet_name,
                      dir_name=sample.name,
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=sample.xSection,
                      sumweights=DYJetsToLL_M50_LO.nevents[0],
                      weight_expr=zl_cut),
            SampleCfg(name='ZJ' + n_jet_name,
                      dir_name=sample.name,
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=sample.xSection,
                      sumweights=DYJetsToLL_M50_LO.nevents[0],
                      weight_expr=zj_cut),
        ]

    samples_data = []
    if channel in ['mt', 'mm']:
        samples_data = [
            SampleCfg(name='data_obs',
                      dir_name='SingleMuon_Run2015D_16Dec',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]
    elif channel in ['et']:
        samples_data = [
            SampleCfg(name='data_obs',
                      dir_name='SingleElectron_Run2015D_16Dec',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]
    elif channel in ['tt']:
        samples_data = [
            SampleCfg(name='data_obs',
                      dir_name='Tau_Run2015D_16Dec',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]

    samples_additional = [
        # SampleCfg(name='TToLeptons_tch', dir_name='TToLeptons_tch_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_amcatnlo.xSection, sumweights=TToLeptons_tch_amcatnlo.nGenEvents),
        SampleCfg(name='TToLeptons_tch_powheg',
                  dir_name='TToLeptons_tch_powheg',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TToLeptons_tch_powheg.xSection,
                  sumweights=TToLeptons_tch_powheg.nGenEvents),
        SampleCfg(name='TBarToLeptons_tch_powheg',
                  dir_name='TBarToLeptons_tch_powheg',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TBarToLeptons_tch_powheg.xSection,
                  sumweights=TBarToLeptons_tch_powheg.nGenEvents),
    ]

    samples_additional += [
        SampleCfg(name='ZZTo4L',
                  dir_name='ZZTo4L',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=ZZTo4L.xSection,
                  sumweights=ZZTo4L.nGenEvents),
        SampleCfg(name='ZZTo2L2Q',
                  dir_name='ZZTo2L2Q',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=ZZTo2L2Q.xSection,
                  sumweights=ZZTo2L2Q.nGenEvents),
        SampleCfg(name='WZTo3L',
                  dir_name='WZTo3LNu',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WZTo3L.xSection,
                  sumweights=WZTo3L.nGenEvents),
        SampleCfg(name='WZTo2L2Q',
                  dir_name='WZTo2L2Q',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WZTo2L2Q.xSection,
                  sumweights=WZTo2L2Q.nGenEvents),
        SampleCfg(name='WZTo1L3Nu',
                  dir_name='WZTo1L3Nu',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WZTo1L3Nu.xSection,
                  sumweights=WZTo1L3Nu.nGenEvents),
        SampleCfg(name='WZTo1L1Nu2Q',
                  dir_name='WZTo1L1Nu2Q',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WZTo1L1Nu2Q.xSection,
                  sumweights=WZTo1L1Nu2Q.nGenEvents),
        # SampleCfg(name='VVTo2L2Nu', dir_name='VVTo2L2Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=VVTo2L2Nu.xSection, sumweights=VVTo2L2Nu.nGenEvents),
        SampleCfg(name='WWTo1L1Nu2Q',
                  dir_name='WWTo1L1Nu2Q',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WWTo1L1Nu2Q.xSection,
                  sumweights=WWTo1L1Nu2Q.nGenEvents),
    ]

    samples_mssm = [
        SampleCfg(name='HiggsSUSYGG200',
                  dir_name='HiggsSUSYGG200',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=100.,
                  sumweights=1.,
                  is_signal=True),
        SampleCfg(name='HiggsSUSYGG500',
                  dir_name='HiggsSUSYGG500',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=100.,
                  sumweights=1.,
                  is_signal=True),
        SampleCfg(name='HiggsSUSYGG1000',
                  dir_name='HiggsSUSYGG1000',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=100.,
                  sumweights=1.,
                  is_signal=True),
        SampleCfg(name='HiggsSUSYGG1500',
                  dir_name='HiggsSUSYGG1500',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=100.,
                  sumweights=1.,
                  is_signal=True),
    ]

    samples_mc = samples_essential + samples_additional + samples_mssm
    samples = samples_essential + samples_data
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)
    for sample in samples_mc:
        if sample.name not in [
                'ZTT1Jets',
                'ZTT2Jets',
                'ZTT3Jets',
                'ZTT4Jets',
                'ZJ1Jets',
                'ZJ2Jets',
                'ZJ3Jets',
                'ZJ4Jets',
                'ZL1Jets',
                'ZL2Jets',
                'ZL3Jets',
                'ZL4Jets',
        ]:
            setSumWeights(sample)

    sampleDict = {s.name: s for s in all_samples}

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #8
0
def createSampleLists(analysis_dir='/afs/cern.ch/user/s/steggema/work/public/mt/NewProd',
                      channel='mt',
                      ztt_cut='(l2_gen_match == 5)*getDYWeight(genboson_mass, genboson_pt)', zl_cut='(l2_gen_match < 5)*getDYWeight(genboson_mass, genboson_pt)',
                      zj_cut='(l2_gen_match == 6)*getDYWeight(genboson_mass, genboson_pt)'):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly
    if channel == 'mt':
        tree_prod_name = 'H2TauTauTreeProducerTauMu'
    elif channel == 'et':
        tree_prod_name = 'H2TauTauTreeProducerTauEle'
    elif channel == 'mm':
        tree_prod_name = 'H2TauTauTreeProducerMuMu'
    elif channel == 'tt':
        tree_prod_name = 'H2TauTauTreeProducerTauTau'
    elif channel == 'em':
        tree_prod_name = 'H2TauTauTreeProducerMuEle'
    elif channel == 'tau_fr':
        tree_prod_name = 'TauFRTreeProducer'

    DYJetsToLL_M50_LO.nGenEvents = 1000.
    # WJetsToLNu_LO.nGenEvents = 1000.

    samples_essential = [
        # SampleCfg(name='ZTTM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=ztt_cut),
        # SampleCfg(name='ZLM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                  # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=zl_cut),
        # SampleCfg(name='ZJM10', dir_name='DYJetsToLL_M10to50', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      # xsec=DYJetsToLL_M10to50_ext1.xSection, sumweights=DYJetsToLL_M10to50_ext1.nGenEvents, weight_expr=zj_cut),
    ]
    if useDYWeight:
        samples_essential += [
            SampleCfg(name='ZTT', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut+dy_exp),
            SampleCfg(name='ZL', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zl_cut+dy_exp),
            SampleCfg(name='ZJ', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut+dy_exp),
            
        ]
    else:
        samples_essential += [
            SampleCfg(name='ZTT', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut),
            SampleCfg(name='ZL', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zl_cut),
            SampleCfg(name='ZJ', dir_name='DYJetsToLL_M50_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
                      xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut),
        ]
        # SampleCfg(name='ZTTM150', dir_name='DYJetsToTauTau_M150_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=ztt_cut+dy_exp),
        # SampleCfg(name='ZLM150', dir_name='DYJetsToTauTau_M150_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zl_cut+dy_exp),
        # SampleCfg(name='ZJM150', dir_name='DYJetsToTauTau_M150_LO', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=DYJetsToLL_M50_LO.xSection, sumweights=DYJetsToLL_M50_LO.nGenEvents, weight_expr=zj_cut+dy_exp),
    samples_essential += [
        # SampleCfg(name='W', dir_name='WJetsToLNu_LO' if channel != 'mm' else 'WJetsToLNu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
        #           xsec=WJetsToLNu_LO.xSection, sumweights=WJetsToLNu_LO.nGenEvents, weight_expr=w_exp if channel != 'tau_fr' else '(geninfo_htgen<100.)'),
        SampleCfg(name='TT', dir_name='TT_pow_ext3', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow_ext.xSection, sumweights=TT_pow_ext.nGenEvents),
        SampleCfg(name='T_tWch', dir_name='T_tWch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=T_tWch.xSection, sumweights=T_tWch.nGenEvents),
        SampleCfg(name='TBar_tWch', dir_name='TBar_tWch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBar_tWch.xSection, sumweights=TBar_tWch.nGenEvents),
        # SampleCfg(name='HiggsGGH125', dir_name='HiggsGGH125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsGGH125.xSection, sumweights=HiggsGGH125.nGenEvents),
        # SampleCfg(name='HiggsVBF125', dir_name='HiggsVBF125', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=HiggsVBF125.xSection, sumweights=HiggsVBF125.nGenEvents),
        # SampleCfg(name='QCD', dir_name='QCD_Mu15', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=QCD_Mu15.xSection)
    ]

    if channel in ['tau_fr']:
        k_factor = '1.'
        samples_essential += [
            # SampleCfg(name='WJetsToLNu_HT100to200', dir_name='WJetsToLNu_HT100to200', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT100to200.xSection, sumweights=WJetsToLNu_HT100to200.nGenEvents, weight_expr=k_factor),
            # SampleCfg(name='WJetsToLNu_HT200to400', dir_name='WJetsToLNu_HT200to400', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT200to400.xSection, sumweights=WJetsToLNu_HT200to400.nGenEvents, weight_expr=k_factor),
            # SampleCfg(name='WJetsToLNu_HT400to600', dir_name='WJetsToLNu_HT400to600', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT400to600.xSection, sumweights=WJetsToLNu_HT400to600.nGenEvents, weight_expr=k_factor),
            # SampleCfg(name='WJetsToLNu_HT600toInf', dir_name='WJetsToLNu_HT600toInf', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu_HT600toInf.xSection, sumweights=WJetsToLNu_HT600toInf.nGenEvents, weight_expr=k_factor),
        ]

    if useDYWeight and channel not in ['mm', 'tau_fr']:
        for sample in DYNJets:
            n_jet_name = str(sample.name[sample.name.find('Jets')-1])+'Jets'
            print 'WARNING - DY - using n(gen events)', DYJetsToLL_M50_LO.nevents[0], 'for DY', n_jet_name
            samples_essential += [
                SampleCfg(name='ZTT'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=DYJetsToLL_M50_LO.nevents[0], weight_expr=ztt_cut+dy_exp),
                SampleCfg(name='ZL'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=DYJetsToLL_M50_LO.nevents[0], weight_expr=zl_cut+dy_exp),
                SampleCfg(name='ZJ'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=DYJetsToLL_M50_LO.nevents[0], weight_expr=zj_cut+dy_exp),
            ]
        for sample in WNJets:
            n_jet_name = str(sample.name[sample.name.find('Jets')-1])+'Jets'
            # print 'WARNING - W - using n(gen events)', WJetsToLNu_LO.nevents[0], 'for W n(jets)', n_jet_name, 'xsec', sample.xSection
            # samples_essential += [
            #     SampleCfg(name='W'+n_jet_name, dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=sample.xSection, sumweights=WJetsToLNu_LO.nevents[0], weight_expr=w_exp)
            # ]

    samples_data = []
    if channel in ['mt', 'mm', 'tau_fr']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleMuon_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['et']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='SingleElectron_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]
    elif channel in ['tt']:
        samples_data = [
            SampleCfg(name='data_obs', dir_name='Tau_Run2016B_PromptReco_v2', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        ]

    samples_additional = [
        # SampleCfg(name='TToLeptons_tch', dir_name='TToLeptons_tch_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_amcatnlo.xSection, sumweights=TToLeptons_tch_amcatnlo.nGenEvents),
        # SampleCfg(name='TToLeptons_tch_powheg', dir_name='TToLeptons_tch_powheg', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_powheg.xSection, sumweights=TToLeptons_tch_powheg.nGenEvents),
        SampleCfg(name='TBarToLeptons_tch_powheg', dir_name='TBarToLeptons_tch_powheg', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBarToLeptons_tch_powheg.xSection, sumweights=TBarToLeptons_tch_powheg.nGenEvents),
        # SampleCfg(name='TToLeptons_tch_powheg', dir_name='TToLeptons_tch_powheg', ana_dir=analysis_dir,
        #           tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_powheg.xSection, sumweights=TToLeptons_tch_powheg.nGenEvents),
    ]

    samples_additional += [
        SampleCfg(name='ZZTo4L', dir_name='ZZTo4L', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZTo4L.xSection, sumweights=ZZTo4L.nGenEvents),
        SampleCfg(name='ZZTo2L2Q', dir_name='ZZTo2L2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZTo2L2Q.xSection, sumweights=ZZTo2L2Q.nGenEvents),
        # SampleCfg(name='WZTo3L', dir_name='WZTo3LNu_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo3LNu_amcatnlo.xSection, sumweights=WZTo3LNu_amcatnlo.nGenEvents),
        SampleCfg(name='WZTo2L2Q', dir_name='WZTo2L2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo2L2Q.xSection, sumweights=WZTo2L2Q.nGenEvents),
        SampleCfg(name='WZTo1L3Nu', dir_name='WZTo1L3Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo1L3Nu.xSection, sumweights=WZTo1L3Nu.nGenEvents),
        SampleCfg(name='WZTo1L1Nu2Q', dir_name='WZTo1L1Nu2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZTo1L1Nu2Q.xSection, sumweights=WZTo1L1Nu2Q.nGenEvents),
        SampleCfg(name='VVTo2L2Nu', dir_name='VVTo2L2Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=VVTo2L2Nu.xSection, sumweights=VVTo2L2Nu.nGenEvents),
        SampleCfg(name='WWTo1L1Nu2Q', dir_name='WWTo1L1Nu2Q', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WWTo1L1Nu2Q.xSection, sumweights=WWTo1L1Nu2Q.nGenEvents),
    ]

    samples_mssm = []
    mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250', 'HiggsSUSYBB300', 'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB900', 'HiggsSUSYBB1000', 'HiggsSUSYBB1200', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2600', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
                  'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG140', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800', 'HiggsSUSYGG900', 'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500', 'HiggsSUSYGG1600', 'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # HiggsSUSYBB800, HiggsSUSYBB1400, HiggsSUSYGG350
    for name in mssm_names:
        samples_mssm.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
                                      ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)
        # SampleCfg(name='HiggsSUSYGG200', dir_name='HiggsSUSYGG200', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG500', dir_name='HiggsSUSYGG500', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG1000', dir_name='HiggsSUSYGG1000', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
        # SampleCfg(name='HiggsSUSYGG1500', dir_name='HiggsSUSYGG1500', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=100., sumweights=1., is_signal=True),
    # ]

    samples_mc = samples_essential + samples_additional + samples_mssm
    samples = samples_essential + samples_data
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    weighted_list = ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']
    if useDYWeight:
        weighted_list += ['ZTT', 'ZTT1Jets', 'ZTT2Jets', 'ZTT3Jets', 'ZTT4Jets',
                          'ZJ', 'ZJ1Jets', 'ZJ2Jets', 'ZJ3Jets', 'ZJ4Jets',
                          'ZL', 'ZL1Jets', 'ZL2Jets', 'ZL3Jets', 'ZL4Jets',
                          'ZTTM150', 'ZJM150', 'ZLM150']

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample, 'MCWeighter' if channel not in ['tau_fr'] else 'SkimAnalyzerCount')

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #9
0
qcd_from_same_sign = False

# -> Command line
analysis_dir = '/afs/cern.ch/user/s/steggema/work/746_pre6/CMSSW_7_4_6_patch6/src/CMGTools/H2TauTau/cfgPython/mt/Prod2015B'
singlet_dir = '/afs/cern.ch/user/s/steggema/work/746_pre6/CMSSW_7_4_6_patch6/src/CMGTools/H2TauTau/cfgPython/mt/ExtraProd2015'
tree_prod_name = 'H2TauTauTreeProducerTauMu'
data_dir = '/afs/cern.ch/user/s/steggema/work/746_pre6/CMSSW_7_4_6_patch6/src/CMGTools/H2TauTau/cfgPython/mt/ExtraDataProd2015'

from CMGTools.RootTools.samples.samples_13TeV_74X import TT_pow, DYJetsToLL_M50, WJetsToLNu, QCD_Mu15, WWTo2L2Nu, ZZp8, WZp8, T_tWch, TBar_tWch, TToLeptons_tch, TToLeptons_sch

# -> Possibly from cfg like in the past, but may also make sense to enter directly
samples = [
    SampleCfg(name='Ztt',
              dir_name='DYJetsToLL_M50',
              ana_dir=analysis_dir,
              tree_prod_name=tree_prod_name,
              xsec=DYJetsToLL_M50.xSection,
              sumweights=DYJetsToLL_M50.nGenEvents,
              weight_expr='weight * (geninfo_TT)'),
    SampleCfg(name='Ztt_ZL',
              dir_name='DYJetsToLL_M50',
              ana_dir=analysis_dir,
              tree_prod_name=tree_prod_name,
              xsec=DYJetsToLL_M50.xSection,
              sumweights=DYJetsToLL_M50.nGenEvents,
              weight_expr='weight * (geninfo_LL && geninfo_fakeid == 1)'),
    SampleCfg(
        name='Ztt_ZJ',
        dir_name='DYJetsToLL_M50',
        ana_dir=analysis_dir,
        tree_prod_name=tree_prod_name,
Beispiel #10
0
def createSampleLists(analysis_dir = '/afs/cern.ch/user/s/steggema/work/public/mt/NewProd',
                      signal_scale = 1.,
                      no_data      = False):
    
    tree_prod_name = 'WTau3MuTreeProducer'

    samples_mc = [
        SampleCfg(name           = 'Signal', 
                  dir_name       = 'WToTauTo3Mu', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name,
                  xsec           = WToTauTo3Mu.xSection, 
                  sumweights     = WToTauTo3Mu.nGenEvents, 
                  weight_expr    = '1.',
                  is_signal      = True,),
    ]

    samples_data = [
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016Bv2_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016C_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016D_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016E_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016F_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016G_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016Hv2_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'DoubleMuonLowMass_Run2016Hv3_03Feb2017', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
    ]
    

    # RIC only for emergency FIXME!
    tree_prod_name = ''

    samples_mc = [
        SampleCfg(name           = 'Signal', 
                  dir_name       = 'signal', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name,
                  xsec           = WToTauTo3Mu.xSection, 
                  sumweights     = WToTauTo3Mu.nGenEvents, 
                  weight_expr    = '1.',
                  is_signal      = True,),
    ]

    samples_data = [
        SampleCfg(name           = 'data_obs', 
                  dir_name       = 'data', 
                  ana_dir        = analysis_dir, 
                  tree_prod_name = tree_prod_name, 
                  is_data        = True),
    ]
    # 
    
    all_samples = samples_mc + samples_data

    sampleDict = {}
    for sample in all_samples:
        sampleDict[sample.name] = sample
        if sample.is_signal:
            sample.scale = sample.scale * signal_scale

    return samples_mc, samples_data, all_samples, sampleDict
Beispiel #11
0
def createSampleLists(analysis_dir='samples/',
                      channel='VV',
                      weight='',
                      signalSample='',
                      vJetsKFac=1.,
                      qcdKFac=1.,
                      useQCDPt=False):

    # settings and code to reweight V+jets samples (EW and QCD NLO corrections)
    # the following two k-factors are from samples_13TeV_RunIISpring16MiniAODv2.py
    # if reweightVJets and reweightVJets2015:
    #     raise AssertionError
    # wJetsKFac = 1.21
    # dyJetsKFac = 1.23
    # wJetsQCDCorrections2015 = {}
    # dyJetsQCDCorrections2015 = {}
    # wJetsQCDCorrections = {}
    # dyJetsQCDCorrections = {}
    # # taken from http://cms.cern.ch/iCMS/jsp/db_notes/noteInfo.jsp?cmsnoteid=CMS%20AN-2015/186 (Table 4)
    # wJetsQCDCorrections2015["WJetsToLNu_HT100to200"] = 1.459/wJetsKFac
    # wJetsQCDCorrections2015["WJetsToLNu_HT200to400"] = 1.434/wJetsKFac
    # wJetsQCDCorrections2015["WJetsToLNu_HT400to600"] = 1.532/wJetsKFac
    # wJetsQCDCorrections2015["WJetsToLNu_HT600to800"] = 1.004/wJetsKFac
    # wJetsQCDCorrections2015["WJetsToLNu_HT800to1200"] = 1.004/wJetsKFac
    # wJetsQCDCorrections2015["WJetsToLNu_HT1200to2500"] = 1.004/wJetsKFac
    # wJetsQCDCorrections2015["WJetsToLNu_HT2500toInf"] = 1.004/wJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT100to200"] = 1.588/dyJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT200to400"] = 1.438/dyJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT400to600"] = 1.494/dyJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT600to800"] = 1.139/dyJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT800to1200"] = 1.139/dyJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT1200to2500"] = 1.139/dyJetsKFac
    # dyJetsQCDCorrections2015["DYJetsToLL_M50_HT2500toInf"] = 1.139/dyJetsKFac
    # # new for Summer16 W+jets (see https://github.com/jmhogan/GenHTweight)
    # wJetsQCDCorrections["WJetsToLNu_HT100to200"] = 0.998056
    # wJetsQCDCorrections["WJetsToLNu_HT200to400"] = 0.978569
    # wJetsQCDCorrections["WJetsToLNu_HT400to600"] = 0.928054
    # wJetsQCDCorrections["WJetsToLNu_HT600to800"] = 0.856705
    # wJetsQCDCorrections["WJetsToLNu_HT800to1200"] = 0.757463
    # wJetsQCDCorrections["WJetsToLNu_HT1200to2500"] = 0.608292
    # wJetsQCDCorrections["WJetsToLNu_HT2500toInf"] = 0.454246
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT100to200"] = 1.007516
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT200to400"] = 0.992853
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT400to600"] = 0.974071
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT600to800"] = 0.948367
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT800to1200"] = 0.883340
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT1200to2500"] = 0.749894
    # dyJetsQCDCorrections["DYJetsToLL_M50_HT2500toInf"] = 0.617254

    # explicit list of samples:
    wjetsSampleNames = ["WJetsToQQ_HT800toInf"]
    dyjetsSampleNames = ['ZJetsToQQ_HT800toInf']
    ttjetsSampleNames = ["TTHad_pow"]
    qcdSampleNames = [
        'QCD_HT100to200', 'QCD_HT200to300', 'QCD_HT300to500', 'QCD_HT500to700',
        'QCD_HT700to1000', 'QCD_HT1000to1500', 'QCD_HT1500to2000',
        'QCD_HT2000toInf'
    ]
    # vvSampleNames = ['WWTo1L1Nu2Q', 'WWTo1L1Nu2Q', 'WZTo1L1Nu2Q']
    # singleTopSampleNames = ['Ttch_powheg', 'TBar_tch_powheg', 'TToLeptons_sch', 'TBar_tWch', 'T_tWch']
    # topSamples = [TT_pow]
    # if useTopMcatnlo:
    #     topSamples = [TTJets]
    #     ttjetsSampleNames = ["TTJets"]
    # if useWJetsPt:
    #     wjetsSampleNames = ["WJetsToLNu_Pt_100To250", "WJetsToLNu_Pt_250To400", "WJetsToLNu_Pt_400To600", "WJetsToLNu_Pt_600ToInf"]

    jj_SampleNames = qcdSampleNames + wjetsSampleNames + dyjetsSampleNames + ttjetsSampleNames
    # cuts to split ttbar sample according to W decay
    # ttjetsWCut = '(lnujj_l2_mergedVTruth==1&&lnujj_l2_nearestBDRTruth>0.8)'
    # ttjetsNonWCut = '(!(lnujj_l2_mergedVTruth==1&&lnujj_l2_nearestBDRTruth>0.8))'
    # add ttbar pT reweighting
    # if reweightTop:
    #     ttjetsWCut += '*truth_genTop_weight'
    #     ttjetsNonWCut += '*truth_genTop_weight'

    tree_prod_name = ''

    # if (channel == "WV"):
    #     channelSampleNames = lnujj_SampleNames
    # else:
    channelSampleNames = jj_SampleNames
    samples_essential = []

    # if "/sVJetsReweighting_cc.so" not in gSystem.GetLibraries():
    #     ROOT.gROOT.ProcessLine(".L %s/src/CMGTools/VVResonances/python/plotting/VJetsReweighting.cc+" % os.environ['CMSSW_BASE'])
    # from ROOT import getDYWeight, getWWeight

    # add samples
    for sample in QCDHT + QCDPt + VJetsQQHT + [TTHad_pow]:
        vJetsWeight = "1."  # str(vJetsKFac)
        if sample.name in channelSampleNames:
            if sample.name in qcdSampleNames:
                vJetsWeight = str(qcdKFac)
            if sample.name in (wjetsSampleNames + dyjetsSampleNames):
                vJetsWeight = str(0.3)
            # if (sample in DYJetsM50HT) and reweightVJets:
            #     vJetsWeight = '{} * {}'.format(vJetsKFac, dyJetsQCDCorrections[sample.name])
            # elif (sample in WJetsToLNuHT) and reweightVJets:
            #     vJetsWeight = '{} * {}'.format(vJetsKFac, wJetsQCDCorrections[sample.name])
            # if (sample in DYJetsM50HT) and reweightVJets2015:
            #     vJetsWeight = 'getDYWeight(truth_genBoson_pt) * {} * {}'.format(vJetsKFac, dyJetsQCDCorrections2015[sample.name])
            # elif (sample in WJetsToLNuHT) and reweightVJets2015:
            #     vJetsWeight = 'getWWeight(truth_genBoson_pt) * {} * {}'.format(vJetsKFac, wJetsQCDCorrections2015[sample.name])
            samples_essential.append(
                SampleCfg(name=sample.name,
                          dir_name=sample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=sample.xSection,
                          sumweights=sample.nGenEvents,
                          weight_expr=('*'.join([weight, vJetsWeight]))))

    # # TTJets sample
    # for sample in topSamples:
    #     if sample.name in channelSampleNames:
    #         # print "Adding", sample.name, sample.xSection, sample.nGenEvents, weight
    #         samples_essential.append(
    #             SampleCfg(name=sample.name+'_W', dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
    #                 xsec=sample.xSection, sumweights=sample.nGenEvents, weight_expr=('*'.join([weight, ttjetsWCut]))))
    #         samples_essential.append(
    #             SampleCfg(name=sample.name+'_nonW', dir_name=sample.name, ana_dir=analysis_dir, tree_prod_name=tree_prod_name,
    #                 xsec=sample.xSection, sumweights=sample.nGenEvents, weight_expr=('*'.join([weight, ttjetsNonWCut]))))

    # signal sample (set signal xsec to 5 pb)
    samples_signal = []
    if (signalSample):
        for sample in signalSamples:
            if sample.name == signalSample:
                samples_signal.append(
                    SampleCfg(name=sample.name,
                              dir_name=sample.name,
                              ana_dir=analysis_dir,
                              tree_prod_name=tree_prod_name,
                              xsec=5.,
                              sumweights=sample.nGenEvents,
                              weight_expr=('*'.join([weight])),
                              is_signal=True))

    samples_data = []
    if channel == 'WV':
        samples_data = [
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016B_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016C_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016D_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016E_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016F_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016G_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016H_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleMuon',
                      dir_name='SingleMuon_Run2016H_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016B_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016C_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016D_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016E_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016F_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016G_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016H_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_SingleElectron',
                      dir_name='SingleElectron_Run2016H_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016B_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016C_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016D_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016E_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016F_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016G_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016H_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_MET',
                      dir_name='MET_Run2016H_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]
    else:
        samples_data = [
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2017B_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2017C_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2017D_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2017E_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_JetHT',
                      dir_name='JetHT_Run2017F_17Nov2017',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
        ]

    # samples_WH = []
    # mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250', 'HiggsSUSYBB300', 'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB900', 'HiggsSUSYBB1000', 'HiggsSUSYBB1200', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2600', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
    #               'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG140', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800', 'HiggsSUSYGG900', 'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500', 'HiggsSUSYGG1600', 'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # HiggsSUSYBB800, HiggsSUSYBB1400, HiggsSUSYGG350
    # for name in mssm_names:
    #     samples_WH.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
    #                                   ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)

    samples_mc = samples_essential + samples_signal
    samples = samples_essential + samples_data + samples_signal
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    weighted_list = []

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample)

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    return samples_mc, samples_data, samples, all_samples, sampleDict
def createSampleLists(
        analysis_dir='/afs/cern.ch/user/s/steggema/work/public/mt/NewProd',
        tree_prod_name='H2TauTauTreeProducerTauMu',
        ztt_cut='(l2_gen_match == 5)',
        zl_cut='(l2_gen_match < 5)',
        zj_cut='(l2_gen_match == 6)'):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly
    samples_essential = [
        SampleCfg(name='ZTT',
                  dir_name='DYJetsToLL_M50_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=DYJetsToLL_M50_LO.xSection,
                  sumweights=DYJetsToLL_M50_LO.nGenEvents,
                  weight_expr=ztt_cut),
        SampleCfg(name='ZL',
                  dir_name='DYJetsToLL_M50_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=DYJetsToLL_M50_LO.xSection,
                  sumweights=DYJetsToLL_M50_LO.nGenEvents,
                  weight_expr=zl_cut),
        SampleCfg(name='ZJ',
                  dir_name='DYJetsToLL_M50_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=DYJetsToLL_M50_LO.xSection,
                  sumweights=DYJetsToLL_M50_LO.nGenEvents,
                  weight_expr=zj_cut),
        SampleCfg(name='W',
                  dir_name='WJetsToLNu_LO',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=WJetsToLNu_LO.xSection,
                  sumweights=WJetsToLNu_LO.nGenEvents,
                  weight_expr='1.'),
        SampleCfg(
            name='TT',
            dir_name='TT_pow_ext' if 'TauEle' in tree_prod_name else 'TT_pow',
            ana_dir=analysis_dir,
            tree_prod_name=tree_prod_name,
            xsec=TT_pow.xSection,
            sumweights=TT_pow.nGenEvents),
        SampleCfg(name='T_tWch',
                  dir_name='T_tWch',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=T_tWch.xSection,
                  sumweights=T_tWch.nGenEvents),
        SampleCfg(name='TBar_tWch',
                  dir_name='TBar_tWch',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TBar_tWch.xSection,
                  sumweights=TBar_tWch.nGenEvents),
        SampleCfg(name='QCD',
                  dir_name='QCD_Mu15',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=QCD_Mu15.xSection)
    ]
    samples_data = []
    if 'TauMu' in tree_prod_name or 'MuMu' in tree_prod_name:
        samples_data = [
            SampleCfg(name='data_obs',
                      dir_name='SingleMuon_Run2015D_v4',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_obs',
                      dir_name='SingleMuon_Run2015D_05Oct',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            # SampleCfg(name='data_obs', dir_name='SingleMuon_Run2015B_05Oct', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True)
        ]
    elif 'TauEle' in tree_prod_name:
        samples_data = [
            SampleCfg(name='data_obs',
                      dir_name='SingleElectron_Run2015D_v4',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            SampleCfg(name='data_obs',
                      dir_name='SingleElectron_Run2015D_05Oct',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      is_data=True),
            # SampleCfg(name='data_obs', dir_name='SingleMuon_Run2015B_05Oct', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True)
        ]

    samples_additional = [
        # SampleCfg(name='TToLeptons_tch', dir_name='TToLeptons_tch_amcatnlo', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch_amcatnlo.xSection, sumweights=TToLeptons_tch_amcatnlo.nGenEvents),
        SampleCfg(name='TToLeptons_tch_powheg',
                  dir_name='TToLeptons_tch_powheg',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TToLeptons_tch_powheg.xSection,
                  sumweights=TToLeptons_tch_powheg.nGenEvents),
        SampleCfg(name='TBarToLeptons_tch_powheg',
                  dir_name='TBarToLeptons_tch_powheg',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TBarToLeptons_tch_powheg.xSection,
                  sumweights=TBarToLeptons_tch_powheg.nGenEvents),
    ]
    if 'TauMu' in tree_prod_name or 'MuMu' in tree_prod_name:
        samples_additional += [
            SampleCfg(name='ZZ',
                      dir_name='ZZp8',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=ZZp8.xSection,
                      sumweights=ZZp8.nGenEvents),
            SampleCfg(name='WZ',
                      dir_name='WZ',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WZp8.xSection,
                      sumweights=WZp8.nGenEvents),
            SampleCfg(name='WW',
                      dir_name='WWTo2L2Nu',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WWTo2L2Nu.xSection,
                      sumweights=WWTo2L2Nu.nGenEvents),
        ]
    else:
        samples_additional += [
            SampleCfg(name='ZZTo4L',
                      dir_name='ZZTo4L',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=ZZTo4L.xSection,
                      sumweights=ZZTo4L.nGenEvents),
            SampleCfg(name='ZZTo2L2Q',
                      dir_name='ZZTo2L2Q',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=ZZTo2L2Q.xSection,
                      sumweights=ZZTo2L2Q.nGenEvents),
            SampleCfg(name='WZTo3L',
                      dir_name='WZTo3L',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WZTo3L.xSection,
                      sumweights=WZTo3L.nGenEvents),
            SampleCfg(name='WZTo2L2Q',
                      dir_name='WZTo2L2Q',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WZTo2L2Q.xSection,
                      sumweights=WZTo2L2Q.nGenEvents),
            SampleCfg(name='WZTo1L3Nu',
                      dir_name='WZTo1L3Nu',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WZTo1L3Nu.xSection,
                      sumweights=WZTo1L3Nu.nGenEvents),
            SampleCfg(name='WZTo1L1Nu2Q',
                      dir_name='WZTo1L1Nu2Q',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WZTo1L1Nu2Q.xSection,
                      sumweights=WZTo1L1Nu2Q.nGenEvents),
            SampleCfg(name='VVTo2L2Nu',
                      dir_name='VVTo2L2Nu',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=VVTo2L2Nu.xSection,
                      sumweights=VVTo2L2Nu.nGenEvents),
            SampleCfg(name='WWTo1L1Nu2Q',
                      dir_name='WWTo1L1Nu2Q',
                      ana_dir=analysis_dir,
                      tree_prod_name=tree_prod_name,
                      xsec=WWTo1L1Nu2Q.xSection,
                      sumweights=WWTo1L1Nu2Q.nGenEvents),
        ]

    samples_mc = samples_essential + samples_additional
    samples = samples_essential + samples_data
    all_samples = samples_mc + samples_data
    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    if not 'MuMu' in tree_prod_name:
        for sample in samples_mc:
            setSumWeights(sample)

    sampleDict = {s.name: s for s in all_samples}

    return samples_mc, samples_data, samples, all_samples, sampleDict
Beispiel #13
0
def createSampleLists(analysis_dir='/data/clange/ntuples/2015_76X_Pruning/',
                      channel='VV',
                      weight=''):
    # -> Possibly from cfg like in the past, but may also make sense to enter directly

    tree_prod_name = ''

    samples_essential = []
    for qcdSample in QCDHT:
        if not ((qcdSample.name.find("_ext") >= 0) or
                (qcdSample.name.find("100to200") >= 0)):
            print qcdSample.name
            samples_essential.append(
                SampleCfg(name=qcdSample.name,
                          dir_name=qcdSample.name,
                          ana_dir=analysis_dir,
                          tree_prod_name=tree_prod_name,
                          xsec=qcdSample.xSection,
                          sumweights=qcdSample.nGenEvents,
                          weight_expr=weight))
    samples_essential.append(
        SampleCfg(name=TTJets.name,
                  dir_name=TTJets.name,
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  xsec=TTJets.xSection,
                  sumweights=TTJets.nGenEvents,
                  weight_expr=weight))

    samples_data = []
    # if channel in ['VV']:
    samples_data = [
        # SampleCfg(name='data_obs', dir_name='JetHT_Run2015C_25ns_16Dec', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, is_data=True),
        SampleCfg(name='data_obs',
                  dir_name='JetHT_Run2015D_16Dec',
                  ana_dir=analysis_dir,
                  tree_prod_name=tree_prod_name,
                  is_data=True),
    ]

    # samples_WH = []
    # mssm_names = ['HiggsSUSYBB80', 'HiggsSUSYBB90', 'HiggsSUSYBB100', 'HiggsSUSYBB110', 'HiggsSUSYBB120', 'HiggsSUSYBB130', 'HiggsSUSYBB140', 'HiggsSUSYBB160', 'HiggsSUSYBB180', 'HiggsSUSYBB200', 'HiggsSUSYBB250', 'HiggsSUSYBB300', 'HiggsSUSYBB350', 'HiggsSUSYBB400', 'HiggsSUSYBB450', 'HiggsSUSYBB500', 'HiggsSUSYBB600', 'HiggsSUSYBB700', 'HiggsSUSYBB900', 'HiggsSUSYBB1000', 'HiggsSUSYBB1200', 'HiggsSUSYBB1500', 'HiggsSUSYBB1600', 'HiggsSUSYBB1800', 'HiggsSUSYBB2000', 'HiggsSUSYBB2300', 'HiggsSUSYBB2600', 'HiggsSUSYBB2900', 'HiggsSUSYBB3200', 'HiggsSUSYGG80', 'HiggsSUSYGG90',
    #               'HiggsSUSYGG100', 'HiggsSUSYGG110', 'HiggsSUSYGG120', 'HiggsSUSYGG130', 'HiggsSUSYGG140', 'HiggsSUSYGG160', 'HiggsSUSYGG180', 'HiggsSUSYGG200', 'HiggsSUSYGG250', 'HiggsSUSYGG300', 'HiggsSUSYGG400', 'HiggsSUSYGG450', 'HiggsSUSYGG500', 'HiggsSUSYGG600', 'HiggsSUSYGG700', 'HiggsSUSYGG800', 'HiggsSUSYGG900', 'HiggsSUSYGG1000', 'HiggsSUSYGG1200', 'HiggsSUSYGG1400', 'HiggsSUSYGG1500', 'HiggsSUSYGG1600', 'HiggsSUSYGG1800', 'HiggsSUSYGG2000', 'HiggsSUSYGG2300', 'HiggsSUSYGG2600', 'HiggsSUSYGG2900', 'HiggsSUSYGG3200']  # HiggsSUSYBB800, HiggsSUSYBB1400, HiggsSUSYGG350
    # for name in mssm_names:
    #     samples_WH.append(SampleCfg(name=name.replace('HiggsSUSYBB', 'bbH').replace('HiggsSUSYGG', 'ggH'), dir_name=name,
    #                                   ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=1., sumweights=1., is_signal=True),)

    samples_mc = samples_essential  # + samples_WH
    samples = samples_essential + samples_data
    all_samples = samples_mc + samples_data

    # -> Can add cross sections for samples either explicitly, or from file, or from cfg
    #    (currently taken from htt_common)

    weighted_list = ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']

    for sample in samples_mc:
        if sample.name not in weighted_list:
            setSumWeights(sample)

    # sampleDict = {s.name: s for s in all_samples}
    sampleDict = {}
    for s in all_samples:
        sampleDict[s.name] = s

    return samples_mc, samples_data, samples, all_samples, sampleDict