예제 #1
0
def main(args):
  LOG.header("Prepare samples")
  sampleset = [
    ('ZTT',  "Z -> #tau_{mu}#tau_{h}", 1.00),
    ('WJ',   "W + jets",               0.40),
    ('QCD',  "QCD multijet",           0.30),
    ('TT',   "t#bar{t}",               0.15),
    ('Data', "Observed",                -1 ),
  ]
  lumi       = 0.001 # [fb-1] to cancel xsec [pb]
  nevts      = args.nevts
  snames     = [n[0] for n in sampleset]
  scales     = {n[0]: n[2] for n in sampleset} # relative contribtions to pseudo data
  outdir     = ensuredir('plots')
  indir      = outdir
  filedict   = makesamples(nevts,sample=snames,scales=scales,outdir=outdir)
  datasample = None
  expsamples = [ ]
  #CMSStyle.setCMSEra(2018)
  setera(2018,lumi)
  for name, title, xsec in sampleset:
    file, tree = filedict[name]
    fname = file.GetName()
    color = None #STYLE.getcolor(name,verb=2)
    data  = name.lower()=='data'
    file.Close()
    sample = Sample(name,title,fname,xsec,color=color,data=data)
    #sample = Sample(name,title,fname,xsec,lumi=lumi,color=color,data=data)
    if sample.isdata:
      datasample = sample
    else:
      expsamples.append(sample)
  plotsamples(datasample,expsamples)
  plotsamples2D(datasample,expsamples)
  testMergedSamples(datasample,expsamples)
예제 #2
0
파일: plotPico.py 프로젝트: yihui-lai/TauFW
def main():
    channel = 'mutau'
    era = 2016
    fname = "$PICODIR/$SAMPLE_$CHANNEL.root"
    setera(era)
    sampleset = makesamples(channel, era, fname)
    plotSampleSet(channel, sampleset, tag="", outdir="plots")
예제 #3
0
def main(args):
  channel = args.channel
  era     = args.era
  parallel = args.parallel
  outdir   = "plots/$ERA"
  histdir  = "hists/$ERA/$CHANNEL$TAG.root"
  tag      = args.tag
  fpattern = args.picopattern

  setera(era) # set era for plot style and lumi-xsec normalization
  sampleset = getsampleset(channel,era,file=fpattern,tag=tag,table=True)
  plot(sampleset,channel,parallel=parallel,tag=tag,outdir=outdir,histdir=histdir,era=era)
예제 #4
0
def main(args):
    LOG.header("Prepare samples")
    sampleset = [
        ('ZTT', "Z -> #tau_{mu}#tau_{h}", 1.00),
        ('WJ', "W + jets", 0.40),
        ('QCD', "QCD multijet", 0.30),
        ('TT', "t#bar{t}", 0.15),
        ('Data', "Observed", -1),
    ]
    lumi = 0.001  # [fb-1] to cancel xsec [pb]
    nevts = args.nevts
    snames = [n[0] for n in sampleset]
    scales = {n[0]: n[2]
              for n in sampleset}  # relative contribtions to pseudo data
    outdir = ensuredir('plots')
    indir = outdir
    filedict = makesamples(nevts, sample=snames, scales=scales, outdir=outdir)
    #CMSStyle.setCMSEra(2018)
    setera(2018, lumi)

    samples = makeSampleSet(sampleset, filedict)
    testget(samples)
    plotSampleSet(samples)
예제 #5
0
def getsampleset(channel, era, **kwargs):
    verbosity = LOG.getverbosity(kwargs)
    year = getyear(era)  # get integer year
    tag = kwargs.get('tag', "")
    table = kwargs.get('table', True)  # print sample set table
    setera(era)  # set era for plot style and lumi normalization

    negative_fractions = {
        "DYJetsToLL_M-50": 0.0004,
        "WJetsToLNu": 0.0004,
        "WW_TuneCP5_13TeV-pythia8":
        0.0,  # <-- no adaption of effective events needed
        "WZ_TuneCP5_13TeV-pythia8":
        0.0,  # <-- no adaption of effective events needed
        "ZZ_TuneCP5_13TeV-pythia8":
        0.0,  # <-- no adaption of effective events needed
        "ST_t-channel_top": 0.033,
        "ST_t-channel_antitop": 0.031,
        "ST_tW_top": 0.002,
        "ST_tW_antitop": 0.002,
        "TTTo2L2Nu": 0.004,
        "TTToHadronic": 0.004,
        "TTToSemiLeptonic": 0.004,
    }

    # SM BACKGROUND MC SAMPLES
    expsamples = [  # table of MC samples to be converted to Sample objects
        # GROUP NAME                     TITLE                 XSEC [pb]      effective NEVENTS = simulated NEVENTS * ( 1  - 2 * negative fraction)

        # Cross-secitons: https://twiki.cern.ch/twiki/bin/viewauth/CMS/StandardModelCrossSectionsat13TeV, Z/a* (50)
        ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 6077.22, {
            "nevts":
            100194597 * (1.0 - 2 * negative_fractions["DYJetsToLL_M-50"])
        }),

        # Cross-sections: https://twiki.cern.ch/twiki/bin/viewauth/CMS/StandardModelCrossSectionsat13TeV, Total W
        ('WJ', "WJetsToLNu", "W + jets", 3 * 20508.9, {
            "nevts": 71072199 * (1.0 - 2 * negative_fractions["WJetsToLNu"])
        }),

        # Cross-sections: https://twiki.cern.ch/twiki/bin/viewauth/CMS/StandardModelCrossSectionsat13TeV, W+ W-
        ('VV', "WW", "WW", 118.7, {
            "nevts": 7850000
        }),

        # Cross-sections: from generator (https://cms-gen-dev.cern.ch/xsdb with 'process_name=WZ_TuneCP5_13TeV-pythia8')
        ('VV', "WZ", "WZ", 27.6, {
            "nevts": 3885000
        }),

        # Cross-sections: from generator (https://cms-gen-dev.cern.ch/xsdb with 'process_name=ZZ_TuneCP5_13TeV-pythia8')
        ('VV', "ZZ", "ZZ", 12.14, {
            "nevts": 1979000
        }),

        # Cross-sections: # https://twiki.cern.ch/twiki/bin/viewauth/CMS/SingleTopSigma
        ('ST', "ST_t-channel_top", "ST t-channel t", 136.02, {
            "nevts":
            154307600 * (1.0 - 2 * negative_fractions["ST_t-channel_top"])
        }),
        ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95, {
            "nevts":
            79090800 * (1.0 - 2 * negative_fractions["ST_t-channel_antitop"])
        }),
        ('ST', "ST_tW_top", "ST tW", 35.85, {
            "nevts": 9598000 * (1.0 - 2 * negative_fractions["ST_tW_top"])
        }),
        ('ST', "ST_tW_antitop", "ST atW", 35.85, {
            "nevts": 7623000 * (1.0 - 2 * negative_fractions["ST_tW_antitop"])
        }),

        # Cross-sections: https://twiki.cern.ch/twiki/bin/view/LHCPhysics/TtbarNNLO#Top_quark_pair_cross_sections_at, m_top = 172.5 GeV + PDG for W boson decays
        ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 831.76 * (3 * 0.1086)**2, {
            "nevts": 64310000 * (1.0 - 2 * negative_fractions["TTTo2L2Nu"])
        }),
        ('TT', "TTToHadronic", "ttbar hadronic",
         831.76 * 2 * (3 * 0.1086) * (0.6741), {
             "nevts":
             199524000 * (1.0 - 2 * negative_fractions["TTToHadronic"])
         }),
        ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 831.76 * (0.6741)**2,
         {
             "nevts":
             199925998 * (1.0 - 2 * negative_fractions["TTToSemiLeptonic"])
         }),
    ]

    # OBSERVED DATA SAMPLES
    if 'mutau' in channel: dataset = "SingleMuon_Run%d?" % year
    elif 'etau' in channel: dataset = "SingleElectron_Run%d?" % year
    else:
        LOG.throw(IOError, "Did not recognize channel %r!" % (channel))
    datasample = ('Data', dataset)  # Data for chosen channel

    # SAMPLE SET
    # TODO section 5: This weight needs to be extended with correction weights common to all simulated samples (MC)
    weight = "genweight/abs(genweight)"  # normalize weight, since sometimes the generator cross-section is contained in it.
    kwargs.setdefault('weight', weight)  # common weight for MC
    sampleset = _getsampleset(datasample,
                              expsamples,
                              channel=channel,
                              era=era,
                              **kwargs)

    # JOIN
    # Note: titles are set via STYLE.sample_titles
    sampleset.join('WW', 'WZ', 'ZZ', name='VV')  # Diboson
    sampleset.join('VV', 'WJ', name='EWK')  # Electroweak

    sampleset.join('TT', name='TT')  # ttbar
    sampleset.join('ST', name='ST')  # single top
    sampleset.join('ST', 'TT', name='Top')  #ttbar & single top

    # SPLIT
    # TODO section 5: Check the generator matching for various samples in the flat n-tuples.
    # Is it justified to require only the tauh candidate to match to generator level hadronic tau to declare the full process with Z->tautau in mutau final state?
    # What is the major contribution from Drell-Yan to genmatch_2!=5? How does this look like for other processes?
    GMR = "genmatch_2==5"
    GMO = "genmatch_2!=5"
    sampleset.split('DY', [('ZTT', GMR), ('ZL', GMO)])
    sampleset.split('Top', [('TopT', GMR), ('TopJ', GMO)])
    sampleset.split('EWK', [('EWKT', GMR), ('EWKJ', GMO)])

    if table:
        sampleset.printtable(merged=True, split=True)
    return sampleset
예제 #6
0
def main(args):
    print ""
    analysis = 'ztt_tid'
    obsset = args.observables
    channels = args.channels
    eras = args.eras
    tag = ""
    bin = 'Tight'
    title = "m_{T} < 60 GeV, D_{#zeta} > -25 GeV, |#Delta#eta| < 1.5"  #"mutau, DeepTau2017v2p1VSjet"
    fname = "$DIR/$ANALYSIS_$OBS_$CHANNEL-$BIN-$ERA$TAG.shapes.root"
    pname = "$DIR/$OBS_$CHANNEL-$BIN-$ERA$TAG_$FIT.png"
    #outfile  = "$TAG/$ANALYSIS_%s_$CHANNEL-$ERA%s.inputs.root"%(obs,tag+outtag)

    # PLOT SETTINGS
    ZTT = "Z -> #tau#tau"  # "Z -> #tau_{#mu}#tau_{h}"
    #STYLE.sample_colors['ZTT'] = STYLE.kOrange-4
    STYLE.sample_titles.update({
        'ZTT': ZTT,
        'ZTT_DM0': ZTT + ", h^{#pm}",
        'ZTT_DM1': ZTT + ", h^{#pm}#pi^{0}",
        'ZTT_DM10': ZTT + ", h^{#pm}h^{#mp}h^{#pm}",
        'ZTT_DM11': ZTT + ", h^{#pm}h^{#mp}h^{#pm}#pi^{0}",
        'ZJ': "Z -> ll",
    })
    procs = [
        'ZTT',
        'ZL',
        'ZJ',
        'TTT',
        'TTJ',
        'W',
        'ST',
        'VV',
        'QCD',
        'data_obs'  #'STT', 'STJ'
    ]
    groups = [
        (['^TT*'], 'Top', 'ttbar'),  #,STYLE.sample_colors['TT']),
        #(['^TT*','ST*'],'Top','ttbar and single top'),
        (['W*', 'ZJ', 'VV', 'ST*',
          'QCD'], 'EWK', 'Electroweak'),  #,STYLE.sample_colors['EWK']),
    ]
    title_dict = {
        'mvis': "m_{vis} (GeV)",
        'mtau': "m(#tau_{h}) (GeV)",
    }
    tsize = 0.054
    PLOT._lsize = 0.040  # label size
    ratio = False
    pos = 'x=0.56,y=0.88'
    ncol = 1
    square = not ratio and False
    exts = ['png', 'pdf', 'root', 'C']
    if "mtau" in obsset:
        procs = ['ZTT_DM0', 'ZTT_DM1', 'ZTT_DM10', 'ZTT_DM11'] + procs[1:]
        pos = 'x=0.22,y=0.85'
        ncol = 2

    # PLOT
    for era in eras:
        setera(era, extra="")
        for channel in channels:
            for obs in obsset:
                indir = "output/%s" % era
                outdir = ensuredir("plots/%s" % era)
                xtitle = title_dict.get(obs)
                fname_ = repkey(fname,
                                DIR=indir,
                                ANALYSIS=analysis,
                                OBS=obs,
                                CHANNEL=channel,
                                BIN=bin,
                                ERA=era,
                                TAG=tag)
                pname_ = repkey(pname,
                                DIR=outdir,
                                ANALYSIS=analysis,
                                OBS=obs,
                                CHANNEL=channel,
                                BIN=bin,
                                ERA=era,
                                TAG=tag)
                drawpostfit(fname_,
                            bin,
                            procs,
                            pname=pname_,
                            tag=tag,
                            group=groups,
                            title=title,
                            xtitle=xtitle,
                            tsize=tsize,
                            pos=pos,
                            ncol=ncol,
                            ratio=ratio,
                            square=square,
                            exts=exts)
예제 #7
0
def getsampleset(channel, era, **kwargs):
    verbosity = LOG.getverbosity(kwargs)
    year = getyear(era)  # get integer year
    dysample = kwargs.get('dy', "jet")
    dyweight = kwargs.get('dyweight', "")
    split = kwargs.get('split',
                       [])  # split samples (e.g. DY) into genmatch components
    join = kwargs.get('join', ['VV', 'Top'])  # join samples (e.g. VV, top)
    tag = kwargs.get('tag', "")
    table = kwargs.get('table', True)  # print sample set table
    setera(era)  # set global era for plot style and lumi-xsec normalization

    if 'UL2016' in era and 'VFP' not in era:  # join pre-/post-VFP into full UL2016
        kwargs['table'] = False
        kwargs1 = kwargs.copy()  # prevent overwriting
        kwargs2 = kwargs.copy()  # prevent overwriting
        sampleset1 = getsampleset(channel, era + "_preVFP", **kwargs1)
        sampleset2 = getsampleset(channel, era + "_postVFP", **kwargs2)
        setera(era)  # reset era for plot style and lumi-xsec normalization
        sampleset = sampleset1 + sampleset2  # merge samples
        if table:
            sampleset.printtable(merged=True, split=True)
        return sampleset

    # SM BACKGROUND MC SAMPLES
    xsec_dy_lo = 4963.0  # MadGraph (LO)
    xsec_dy_nlo = 6529.0  # aMC@NLO
    xsec_dy_nnlo = 3 * 2025.74  # FEWZ (NNLO)
    k_lo = xsec_dy_nnlo / xsec_dy_lo
    k_nlo = 1.  #xsec_dy_nnlo/xsec_dy_nlo
    if 'UL' in era:
        expsamples = [  # table of MC samples to be converted to Sample objects
            # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
            #( 'DY', "DYJetsToLL_M-10to50",   "Drell-Yan 10-50",    18610.0  ),
            ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 5343.0, {
                'extraweight': dyweight
            }),
            ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 877.8, {
                'extraweight': dyweight
            }),
            ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 304.4, {
                'extraweight': dyweight
            }),
            ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 111.5, {
                'extraweight': dyweight
            }),
            ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 44.05, {
                'extraweight': dyweight
            }),
            ###( 'DY', "DYJetsToMuTauh_M-50",   "DYJetsToMuTauh_M-50", 5343.0, {'extraweight': dyweight} ),
            ('WJ', "WJetsToLNu", "W + jets", 52940.0),
            ('WJ', "W1JetsToLNu", "W + 1J", 8104.0),
            ('WJ', "W2JetsToLNu", "W + 2J", 2793.0),
            ('WJ', "W3JetsToLNu", "W + 3J", 992.5),
            ('WJ', "W4JetsToLNu", "W + 4J", 544.3),
            ('VV', "WW", "WW", 75.88),
            ('VV', "WZ", "WZ", 27.6),
            ('VV', "ZZ", "ZZ", 12.14),
            ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
            ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
            ('ST', "ST_tW_top", "ST tW", 35.85),
            ('ST', "ST_tW_antitop", "ST atW", 35.85),
            ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 88.29, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToHadronic", "ttbar hadronic", 377.96, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 365.35, {
                'extraweight': 'ttptweight'
            }),
        ]
    else:
        if era == '2016':
            expsamples = [
            ]  # table of MC samples to be converted to Sample objects
            if 'mass' in dysample:
                expsamples += [
                    # GROUP NAME                       TITLE                   XSEC             EXTRA OPTIONS
                    ('DY', "DYJetsToLL_M-100to200", "Drell-Yan 100to200",
                     k_nlo * 226.6, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-200to400", "Drell-Yan 200to400",
                     k_nlo * 7.77, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-400to500", "Drell-Yan 400to500",
                     k_nlo * 0.4065, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-500to700", "Drell-Yan 500to700",
                     k_nlo * 0.2334, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-700to800", "Drell-Yan 700to800",
                     k_nlo * 0.03614, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-800to1000", "Drell-Yan 800to1000",
                     k_nlo * 0.03047, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-1000to1500", "Drell-Yan 1000to1500",
                     k_nlo * 0.01636, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-1500to2000", "Drell-Yan 1500to2000",
                     k_nlo * 0.00218, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-2000to3000", "Drell-Yan 2000to3000",
                     k_nlo * 0.0005156, {
                         'extraweight': dyweight
                     }),
                ]
            else:
                expsamples += [
                    # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
                    ('DY', "DYJetsToLL_M-10to50", "Drell-Yan 10-50", 18610.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 4963.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 1012.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 334.7, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 102.3, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 54.52, {
                        'extraweight': dyweight
                    }),
                ]
            expsamples += [
                # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
                ('WJ', "WJetsToLNu", "W + jets", 50260.0),
                ('WJ', "W1JetsToLNu", "W + 1J", 9625.0),
                ('WJ', "W2JetsToLNu", "W + 2J", 3161.0),
                ('WJ', "W3JetsToLNu", "W + 3J", 954.8),
                ('WJ', "W4JetsToLNu", "W + 4J", 494.6),
                ('VV', "WW", "WW", 75.88),
                ('VV', "WZ", "WZ", 27.6),
                ('VV', "ZZ", "ZZ", 12.14),
                ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
                ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
                ('ST', "ST_tW_top", "ST tW", 35.85),
                ('ST', "ST_tW_antitop", "ST atW", 35.85),
                ('TT', "TT", "ttbar", 831.76, {
                    'extraweight': 'ttptweight'
                }),
            ]
        elif era == '2017':
            expsamples = [
            ]  # table of MC samples to be converted to Sample objects
            if 'mass' in dysample:
                expsamples += [
                    # GROUP NAME                       TITLE                   XSEC             EXTRA OPTIONS
                    ('DY', "DYJetsToLL_M-100to200", "Drell-Yan 100to200",
                     k_nlo * 247.8, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-200to400", "Drell-Yan 200to400",
                     k_nlo * 8.502, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-400to500", "Drell-Yan 400to500",
                     k_nlo * 0.4514, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-500to700", "Drell-Yan 500to700",
                     k_nlo * 0.2558, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-700to800", "Drell-Yan 700to800",
                     k_nlo * 0.04023, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-800to1000", "Drell-Yan 800to1000",
                     k_nlo * 0.03406, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-1000to1500", "Drell-Yan 1000to1500",
                     k_nlo * 0.01828, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-1500to2000", "Drell-Yan 1500to2000",
                     k_nlo * 0.002367, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-2000to3000", "Drell-Yan 2000to3000",
                     k_nlo * 0.0005409, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-3000toInf", "Drell-Yan 3000toInf",
                     k_nlo * 3.048e-05, {
                         'extraweight': dyweight
                     }),
                ]
            else:
                expsamples += [
                    # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
                    ('DY', "DYJetsToLL_M-10to50", "Drell-Yan 10-50", 18610.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 5343.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 877.8, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 304.4, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 111.5, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 44.05, {
                        'extraweight': dyweight
                    }),
                ]
            expsamples += [
                # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
                ('WJ', "WJetsToLNu", "W + jets", 52940.0),
                ('WJ', "W1JetsToLNu", "W + 1J", 8104.0),
                ('WJ', "W2JetsToLNu", "W + 2J", 2793.0),
                #( 'WJ', "W3JetsToLNu",           "W + 3J",               992.5  ),
                ('WJ', "W4JetsToLNu", "W + 4J", 544.3),
                ('VV', "WW", "WW", 75.88),
                ('VV', "WZ", "WZ", 27.6),
                ('VV', "ZZ", "ZZ", 12.14),
                ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
                ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
                ('ST', "ST_tW_top", "ST tW", 35.85),
                ('ST', "ST_tW_antitop", "ST atW", 35.85),
                ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 88.29, {
                    'extraweight': 'ttptweight'
                }),
                ('TT', "TTToHadronic", "ttbar hadronic", 377.96, {
                    'extraweight': 'ttptweight'
                }),
                ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 365.35, {
                    'extraweight': 'ttptweight'
                }),
            ]
        elif era == '2018':
            expsamples = [
            ]  # table of MC samples to be converted to Sample objects
            if 'mass' in dysample:
                expsamples += [
                    # GROUP NAME                       TITLE                   XSEC             EXTRA OPTIONS
                    ('DY', "DYJetsToLL_M-100to200", "Drell-Yan 100to200",
                     k_nlo * 247.8, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-200to400", "Drell-Yan 200to400",
                     k_nlo * 8.502, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-400to500", "Drell-Yan 400to500",
                     k_nlo * 0.4514, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-500to700", "Drell-Yan 500to700",
                     k_nlo * 0.2558, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-700to800", "Drell-Yan 700to800",
                     k_nlo * 0.04023, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-800to1000", "Drell-Yan 800to1000",
                     k_nlo * 0.03406, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-1000to1500", "Drell-Yan 1000to1500",
                     k_nlo * 0.01828, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-1500to2000", "Drell-Yan 1500to2000",
                     k_nlo * 0.002367, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-2000to3000", "Drell-Yan 2000to3000",
                     k_nlo * 0.0005409, {
                         'extraweight': dyweight
                     }),
                    ('DY', "DYJetsToLL_M-3000toInf", "Drell-Yan 3000toInf",
                     k_nlo * 3.048e-05, {
                         'extraweight': dyweight
                     }),
                ]
            else:
                expsamples += [
                    # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
                    ('DY', "DYJetsToLL_M-10to50", "Drell-Yan 10-50", 18610.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 5343.0, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 877.8, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 304.4, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 111.5, {
                        'extraweight': dyweight
                    }),
                    ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 44.05, {
                        'extraweight': dyweight
                    }),
                ]
            expsamples += [
                # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
                ('WJ', "WJetsToLNu", "W + jets", 52940.0),
                ('WJ', "W1JetsToLNu", "W + 1J", 8104.0),
                ('WJ', "W2JetsToLNu", "W + 2J", 2793.0),
                ('WJ', "W3JetsToLNu", "W + 3J", 992.5),
                ('WJ', "W4JetsToLNu", "W + 4J", 544.3),
                ('VV', "WW", "WW", 75.88),
                ('VV', "WZ", "WZ", 27.6),
                ('VV', "ZZ", "ZZ", 12.14),
                ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
                ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
                ('ST', "ST_tW_top", "ST tW", 35.85),
                ('ST', "ST_tW_antitop", "ST atW", 35.85),
                ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 88.29, {
                    'extraweight': 'ttptweight'
                }),
                ('TT', "TTToHadronic", "ttbar hadronic", 377.96, {
                    'extraweight': 'ttptweight'
                }),
                ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 365.35, {
                    'extraweight': 'ttptweight'
                }),
            ]
        else:
            LOG.throw(IOError, "Did not recognize era %r!" % (era))

    # OBSERVED DATA SAMPLES
    dataset = "SingleMuon_Run%d?" % year
    datasample = ('Data', dataset)  # GROUP, NAME

    # SAMPLE SET
    weight = "genweight*trigweight*puweight*idisoweight_1*idisoweight_2"
    fname = "$PICODIR/$SAMPLE_$CHANNEL$TAG.root"
    kwargs.setdefault('weight', weight)  # common weight for MC
    kwargs.setdefault('fname', fname)  # default filename pattern
    sampleset = _getsampleset(datasample,
                              expsamples,
                              channel=channel,
                              era=era,
                              **kwargs)

    # JOIN
    ZMM = STYLE.sample_titles.get('ZMM', "Z -> mumu")  # title
    # Note: titles are set via STYLE.sample_titles
    sampleset.stitch("W*Jets", incl='WJ', name='WJ')  # W + jets
    if 'mass' not in dysample:
        sampleset.stitch("DY*J*M-10to50", incl='DYJ', name="DY_M10to50")
        sampleset.stitch("DY*J*M-50", incl='DYJ',
                         name='DY')  # Drell-Yan, M > 50 GeV
    sampleset.join('DY', name='DY')  # Drell-Yan, M < 50 GeV + M > 50 GeV
    if 'VV' in join:
        sampleset.join('VV', 'WZ', 'WW', 'ZZ', name='VV')  # Diboson
    if 'TT' in join and era != 'year':
        sampleset.join('TT', name='TT')  # ttbar
    if 'ST' in join:
        sampleset.join('ST', name='ST')  # single top
    if 'Top' in join:
        sampleset.join('TT', 'ST', name='Top')  # ttbar + single top

    # SPLIT
    GMR = "genmatch_1>0 && genmatch_2>0"
    GMF = "(genmatch_1<=0 || genmatch_2<=0)"
    if 'DY' in split:
        sampleset.split('DY', [
            ('ZMM', ZMM, GMR),
            ('ZJ', GMF),
        ])
    if 'TT' in split:
        sampleset.split('TT', [
            ('TMM', GMR),
            ('TTJ', GMF),
        ])

    if table:
        sampleset.printtable(merged=True, split=True)
    return sampleset
예제 #8
0
파일: postfit.py 프로젝트: slehti/TauFW
def drawpostfit(fname, bin, procs, **kwargs):
    """Plot pre- and post-fit plots PostFitShapesFromWorkspace."""
    print '>>>\n>>> drawpostfit("%s","%s")' % (fname, bin)
    outdir = kwargs.get('outdir', "")
    pname = kwargs.get('pname',
                       "$FIT.png")  # replace $FIT = 'prefit', 'postfit'
    ratio = kwargs.get('ratio', True)
    tag = kwargs.get('tag', "")
    xtitle = kwargs.get('xtitle', None)
    title = kwargs.get('title', None)
    text = kwargs.get('text', "")
    tsize = kwargs.get('tsize', 0.050)
    xmin = kwargs.get('xmin', None)
    xmax = kwargs.get('xmax', None)
    ymargin = kwargs.get('ymargin', 1.22)
    groups = kwargs.get('group', [])
    position = kwargs.get('pos', None)  # legend position
    ncol = kwargs.get('ncol', None)  # legend columns
    square = kwargs.get('square', False)
    era = kwargs.get('era', "")
    exts = kwargs.get('exts', ['pdf', 'png'])  # figure extension
    ymax = None
    fits = ['prefit', 'postfit']
    file = ensureTFile(fname, 'READ')
    if outdir:
        ensuredir(outdir)
    if era:
        setera(era)

    # DRAW PRE-/POST-FIT
    for fit in fits:
        fitdirname = "%s_%s" % (bin, fit)
        dir = file.Get(fitdirname)
        if not dir:
            LOG.warning('drawpostfit: Did not find dir "%s"' % (fitdirname),
                        pre="   ")
            return
        obshist = None
        exphists = []

        # GET HIST
        for proc in procs:  #reversed(samples):
            hname = "%s/%s" % (fitdirname, proc)
            hist = file.Get(hname)
            if not hist:
                LOG.warning(
                    'drawpostfit: Could not find "%s" template in directory "%s_%s"'
                    % (proc, bin, fit),
                    pre="   ")
                continue
            if 'data_obs' in proc:
                obshist = hist
                hist.SetLineColor(1)
                ymax = hist.GetMaximum() * ymargin
            else:
                exphists.append(hist)
            if proc in STYLE.sample_titles:
                hist.SetTitle(STYLE.sample_titles[proc])
            if proc in STYLE.sample_colors:
                hist.SetFillStyle(1001)
                hist.SetFillColor(STYLE.sample_colors[proc])
        if len(exphists) == 0:
            LOG.warning(
                'drawpostfit: Could not find any templates in directory "%s"' %
                (bin),
                pre="   ")
            continue
        if not obshist:
            LOG.warning(
                'drawpostfit: Could not find a data template in directory "%s"'
                % (bin),
                pre="   ")
            continue
        for groupargs in groups:
            grouphists(exphists, *groupargs, replace=True)

        # PLOT
        xtitle = (xtitle or exphists[0].GetXaxis().GetTitle()
                  )  #.replace('[GeV]','(GeV)')
        xmax = xmax or exphists[0].GetXaxis().GetXmax()
        xmin = xmin or exphists[0].GetXaxis().GetXmin()
        errtitle = "Pre-fit stat. + syst. unc." if fit == 'prefit' else "Post-fit unc."
        pname_ = repkey(pname, FIT=fit, ERA=era)
        rmin, rmax = (0.28, 1.52)
        plot = Stack(xtitle, obshist, exphists)
        plot.draw(xmin=xmin,
                  xmax=xmax,
                  ymax=ymax,
                  square=square,
                  ratio=ratio,
                  rmin=rmin,
                  rmax=rmax,
                  staterror=True,
                  errtitle=errtitle)
        plot.drawlegend(position, tsize=tsize, text=text, ncol=ncol)
        if title:
            plot.drawtext(title, bold=False)
        plot.saveas(pname_, outdir=outdir, ext=exts)
        plot.close()

    file.Close()
예제 #9
0
def getsampleset(channel, era, **kwargs):
    verbosity = LOG.getverbosity(kwargs)
    year = getyear(era)  # get integer year
    split = kwargs.get(
        'split', ['DY'])  # split samples (e.g. DY) into genmatch components
    join = kwargs.get('join', ['VV', 'Top'])  # join samples (e.g. VV, top)
    tag = kwargs.get('tag', "")
    table = kwargs.get('table', True)  # print sample set table
    setera(era)  # set era for plot style and lumi-xsec normalization

    # SM BACKGROUND MC SAMPLES
    if era == '2016':
        expsamples = [  # table of MC samples to be converted to Sample objects
            # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
            ('DY', "DYJetsToLL_M-10to50", "Drell-Yan 10-50", 18610.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 4963.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 1012.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 334.7, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 102.3, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 54.52, {
                'extraweight': 'zptweight'
            }),
            ('WJ', "WJetsToLNu", "W + jets", 50260.0),
            ('WJ', "W1JetsToLNu", "W + 1J", 9625.0),
            ('WJ', "W2JetsToLNu", "W + 2J", 3161.0),
            ('WJ', "W3JetsToLNu", "W + 3J", 954.8),
            ('WJ', "W4JetsToLNu", "W + 4J", 494.6),
            ('VV', "WW", "WW", 75.88),
            ('VV', "WZ", "WZ", 27.6),
            ('VV', "ZZ", "ZZ", 12.14),
            ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
            ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
            ('ST', "ST_tW_top", "ST tW", 35.85),
            ('ST', "ST_tW_antitop", "ST atW", 35.85),
            ('TT', "TT", "ttbar", 831.76, {
                'extraweight': 'ttptweight'
            }),
        ]
    elif era == '2017':
        expsamples = [  # table of MC samples to be converted to Sample objects
            # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
            ('DY', "DYJetsToLL_M-10to50", "Drell-Yan 10-50", 18610.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 5343.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 877.8, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 304.4, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 111.5, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 44.05, {
                'extraweight': 'zptweight'
            }),
            ('WJ', "WJetsToLNu", "W + jets", 52940.0),
            ('WJ', "W1JetsToLNu", "W + 1J", 8104.0),
            ('WJ', "W2JetsToLNu", "W + 2J", 2793.0),
            ('WJ', "W3JetsToLNu", "W + 3J", 992.5),
            ('WJ', "W4JetsToLNu", "W + 4J", 544.3),
            ('VV', "WW", "WW", 75.88),
            ('VV', "WZ", "WZ", 27.6),
            ('VV', "ZZ", "ZZ", 12.14),
            ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
            ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
            ('ST', "ST_tW_top", "ST tW", 35.85),
            ('ST', "ST_tW_antitop", "ST atW", 35.85),
            ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 88.29, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToHadronic", "ttbar hadronic", 377.96, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 365.35, {
                'extraweight': 'ttptweight'
            }),
        ]
    elif era == 'UL2017':
        expsamples = [  # table of MC samples to be converted to Sample objects
            # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
            #( 'DY', "DYJetsToLL_M-10to50",   "Drell-Yan 10-50",    18610.0, {'extraweight': 'zptweight'} ),
            ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 5343.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 877.8, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 304.4, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 111.5, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 44.05, {
                'extraweight': 'zptweight'
            }),
            ('WJ', "WJetsToLNu", "W + jets", 52940.0),
            ('WJ', "W1JetsToLNu", "W + 1J", 8104.0),
            ('WJ', "W2JetsToLNu", "W + 2J", 2793.0),
            ('WJ', "W3JetsToLNu", "W + 3J", 992.5),
            ('WJ', "W4JetsToLNu", "W + 4J", 544.3),
            ('VV', "WW", "WW", 75.88),
            ('VV', "WZ", "WZ", 27.6),
            ('VV', "ZZ", "ZZ", 12.14),
            ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
            ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
            ('ST', "ST_tW_top", "ST tW", 35.85),
            ('ST', "ST_tW_antitop", "ST atW", 35.85),
            ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 88.29, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToHadronic", "ttbar hadronic", 377.96, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 365.35, {
                'extraweight': 'ttptweight'
            }),
        ]
    elif era == '2018':
        expsamples = [  # table of MC samples to be converted to Sample objects
            # GROUP NAME                     TITLE                 XSEC      EXTRA OPTIONS
            ('DY', "DYJetsToLL_M-10to50", "Drell-Yan 10-50", 18610.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DYJetsToLL_M-50", "Drell-Yan 50", 4963.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY1JetsToLL_M-50", "Drell-Yan 1J 50", 1012.0, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY2JetsToLL_M-50", "Drell-Yan 2J 50", 334.7, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY3JetsToLL_M-50", "Drell-Yan 3J 50", 102.3, {
                'extraweight': 'zptweight'
            }),
            ('DY', "DY4JetsToLL_M-50", "Drell-Yan 4J 50", 54.52, {
                'extraweight': 'zptweight'
            }),
            ('WJ', "WJetsToLNu", "W + jets", 52940.0),
            ('WJ', "W1JetsToLNu", "W + 1J", 8104.0),
            ('WJ', "W2JetsToLNu", "W + 2J", 2793.0),
            ('WJ', "W3JetsToLNu", "W + 3J", 992.5),
            ('WJ', "W4JetsToLNu", "W + 4J", 544.3),
            ('VV', "WW", "WW", 75.88),
            ('VV', "WZ", "WZ", 27.6),
            ('VV', "ZZ", "ZZ", 12.14),
            ('ST', "ST_t-channel_top", "ST t-channel t", 136.02),
            ('ST', "ST_t-channel_antitop", "ST t-channel at", 80.95),
            ('ST', "ST_tW_top", "ST tW", 35.85),
            ('ST', "ST_tW_antitop", "ST atW", 35.85),
            ('TT', "TTTo2L2Nu", "ttbar 2l2#nu", 88.29, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToHadronic", "ttbar hadronic", 377.96, {
                'extraweight': 'ttptweight'
            }),
            ('TT', "TTToSemiLeptonic", "ttbar semileptonic", 365.35, {
                'extraweight': 'ttptweight'
            }),
        ]
    else:
        LOG.throw(IOError, "Did not recognize era %r!" % (era))

    # OBSERVED DATA SAMPLES
    if 'tautau' in channel: dataset = "Tau_Run%d?" % year
    elif 'mutau' in channel: dataset = "SingleMuon_Run%d?" % year
    elif 'etau' in channel:
        dataset = "EGamma_Run%d?" % year if year == 2018 else "SingleElectron_Run%d?" % year
    elif 'mumu' in channel:
        dataset = "SingleMuon_Run%d?" % year
    elif 'emu' in channel:
        dataset = "SingleMuon_Run%d?" % year
    elif 'ee' in channel:
        dataset = "EGamma_Run%d?" % year if year == 2018 else "SingleElectron_Run%d?" % year
    else:
        LOG.throw(IOError, "Did not recognize channel %r!" % (channel))
    datasample = ('Data', dataset)  # GROUP, NAME

    # SAMPLE SET
    weight = "genweight*trigweight*puweight*idisoweight_1*idweight_2"
    if era == 'UL2017':
        weight = weight.replace("*idweight_2", "")
    fname = "$PICODIR/$SAMPLE_$CHANNEL$TAG.root"
    kwargs.setdefault('weight', weight)  # common weight for MC
    kwargs.setdefault('fname', fname)  # default filename pattern
    sampleset = _getsampleset(datasample,
                              expsamples,
                              channel=channel,
                              era=era,
                              **kwargs)

    # JOIN
    # Note: titles are set via STYLE.sample_titles
    sampleset.stitch("W*Jets", incl='WJ', name='WJ')  # W + jets
    sampleset.stitch("DY*J*M-50", incl='DYJ',
                     name="DY_M50")  # Drell-Yan, M > 50 GeV
    #sampleset.stitch("DY*J*M-10to50", incl='DYJ', name="DY_M10to50" )
    sampleset.join('DY', name='DY')  # Drell-Yan, M < 50 GeV + M > 50 GeV
    if 'VV' in join:
        sampleset.join('VV', 'WZ', 'WW', 'ZZ', name='VV')  # Diboson
    if 'TT' in join and era != 'year':
        sampleset.join('TT', name='TT')  # ttbar
    if 'ST' in join:
        sampleset.join('ST', name='ST')  # single top
    if 'Top' in join:
        sampleset.join('TT', 'ST', name='Top')  # ttbar + single top

    # SPLIT
    # Note: titles are set via STYLE.sample_titles
    if split and channel.count('tau') == 1:
        ZTT = STYLE.sample_titles.get('ZTT', "Z -> %s" % channel)  # title
        if channel.count('tau') == 1:
            ZTT = ZTT.replace("{l}", "{mu}" if "mu" in channel else "{e}")
            GMR = "genmatch_2==5"
            GML = "genmatch_2>0 && genmatch_2<5"
            GMJ = "genmatch_2==0"
            GMF = "genmatch_2<5"
        elif channel.count('tau') == 2:
            ZTT = ZTT.replace("{l}", "{h}")
            GMR = "genmatch_1==5 && genmatch_2==5"
            GML = "(genmatch_1<5 || genmatch_2<5) && genmatch_1>0 && genmatch_2>0"
            GMJ = "(genmatch_1==0 || genmatch_2==0)"
            GMF = "(genmatch_1<5 || genmatch_2<5)"
        else:
            LOG.throw(IOError, "Did not recognize channel %r!" % (channel))
        if 'DY' in split:
            sampleset.split('DY', [
                ('ZTT', ZTT, GMR),
                ('ZL', GML),
                ('ZJ', GMJ),
            ])
        if 'DM' in split:  # split DY by decay modes
            samples.split('DY', [
                ('ZTT_DM0', ZTT + ", h^{#pm}", GMR + " && decayMode_2==0"),
                ('ZTT_DM1', ZTT + ", h^{#pm}h^{0}",
                 GMR + " && decayMode_2==1"),
                ('ZTT_DM10', ZTT + ", h^{#pm}h^{#mp}h^{#pm}",
                 GMR + " && decayMode_2==10"),
                ('ZTT_DM11', ZTT + ", h^{#pm}h^{#mp}h^{#pm}h^{0}",
                 GMR + " && decayMode_2==11"),
                ('ZL', GML),
                ('ZJ', GMJ),
            ])
        if 'TT' in split:
            sampleset.split('TT', [
                ('TTT', GMR),
                ('TTJ', GMF),
            ])

    if table:
        sampleset.printtable(merged=True, split=True)
    return sampleset