from PhysicsTools.NanoAODTools.postprocessing.modules.Dataset import *
import os

#Input which era
#era = eval(cfg.dataset())
#print "cfg.dataset() =", cfg.dataset()

sample ={}
for idataset in era:
    sample['%s'%idataset.filename()] ={}
    sample['%s'%idataset.filename()]['nevents'] = idataset.nevent()
    sample['%s'%idataset.filename()]['xsec'] = idataset.xsec()
    sample['%s'%idataset.filename()]['kfactor'] = idataset.kfactor()
    sample['%s'%idataset.filename()]['matcheff'] = idataset.matcheff()

samples = {
    'data_obs' : {
        'order' : 0,
        'files' : [ x.filename() for x in era if x.name() == 'data_obs' and x.active() ],
        'fillcolor' : 0,
        'fillstyle' : 1,
        'linecolor' : 1,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "Data",
        'weight': 1.,
        'plot': True,
    },
    'DYJetsToLL' : {
        'order' : 1,
        'files' : [ x.filename() for x in era if x.name() == 'DYJetsToLL' and x.active() ],
        'fillcolor' : 418,
        'fillstyle' : 1001,
        'linecolor' : 418,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "Z(ll) + jets",
        'weight': 1.,
        'plot': True,
    },
    'DYJetsToLL_HT' : {
            'order' : 1,
            'files' : [ x.filename() for x in era if x.name() == 'DYJetsToLL_HT' and x.active() ],
            'fillcolor' : 418,
            'fillstyle' : 1001,
            'linecolor' : 418,
            'linewidth' : 2,
            'linestyle' : 1,
            'label' : "Z(ll) + jets",
            'weight': 1.,
            'plot': True,
    },
    'DYJetsToLL_Pt' : {
        'order' : 2,
        'files' : [ x.filename() for x in era if x.name() == 'DYJetsToLL_Pt' and x.active() ],
        'fillcolor' : 418,
        'fillstyle' : 1001,
        'linecolor' : 418,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "Z(ll) + jets",
        'weight': 1.,
        'plot': True,
        },
    'WJetsToLNu' : {
        'order' : 3,
        'files' : [ x.filename() for x in era if x.name() == 'WJetsToLNu' and x.active() ],
        'fillcolor' : 881,
        'fillstyle' : 1001,
        'linecolor' : 881,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W(l#nu) + jets",
        'weight': 1.,
        'plot': True,
    },
    'WJetsToLNu_HT' : {
        'order' : 3,
        'files' : [ x.filename() for x in era if x.name() == 'WJetsToLNu_HT' and x.active() ],
	    'fillcolor' : 881,
        'fillstyle' : 1001,
        'linecolor' : 881,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W(l#nu) + jets",
        'weight': 1.,
        'plot': True,
    },
    'TTbar' : {
        'order' : 4,
        'files' : [ x.filename() for x in era if x.name() == 'TTbar' and x.active() ],
        'fillcolor' : 798,
        'fillstyle' : 1001,
        'linecolor' : 798,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "t#bar{t}",#, single t
        'weight': 1.,
        'plot': True,
    },
    'TTbar-DiLept' : {
        'order' : 4,
        'files' : [ x.filename() for x in era if x.name() == 'TTBar-DiLept' and x.active() ],
        'fillcolor' : 41,
        'fillstyle' : 1001,
        'linecolor' : 798,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "t#bar{t} di-lept",#, single t
        'weight': 1.,
        'plot': True,
    },
    'TTbar-SL' : {
        'order' : 4,
        'files' : [ x.filename() for x in era if x.name() == 'TTbar-SL' and x.active() ],
        'fillcolor' : 798,
        'fillstyle' : 1001,
        'linecolor' : 798,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "t#bar{t} sing.lept",
        'weight': 1.,
        'plot': True,
    },
    'ST' : {
        'order' : 5,
        'files' : [ x.filename() for x in era if x.name() == 'ST' and x.active() ],
        'fillcolor' : 801,
        'fillstyle' : 1001,
        'linecolor' : 801,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "Single-t",
        'weight': 1.,
        'plot': True,
        },
    'WZ' : {
        'order' : 7,
        'files' : [ x.filename() for x in era if x.name() == 'WZ' and x.active() ],
        'fillcolor' : 602,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "WZ",
        'weight': 1.,
        'plot': True,
        },
     'WW' : {
        'order' : 9,
        'files' : [ x.filename() for x in era if x.name() == 'WW' and x.active() ],
        'fillcolor' : 7,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "WW",
        'weight': 1.,
        'plot': True,
        },
    'ZZ' : {
        'order' : 8,
        'files' : [ x.filename() for x in era if x.name() == 'ZZ' and x.active() ],
        'fillcolor' : 9,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "ZZ",
        'weight': 1.,
        'plot': True,
        },
    'VV' : {
        'order' : 8,
        'files' : [ x.filename() for x in era if x.name() == 'VV' and x.active() ],
        'fillcolor' : 9,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "WW, WZ, ZZ",
        'weight': 1.,
        'plot': True,
    },
    'ttH' : {
        'order' : 10,
        'files' : [ x.filename() for x in era if x.name() == 'ttH' and x.active() ],
        'fillcolor' : 30,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "ttH",
        'weight': 1.,
        'plot': True,
        },
    'ttV' : {
        'order' : 10,
        'files' : [ x.filename() for x in era if x.name() == 'ttV' and x.active() ],
        'fillcolor' : 38,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "ttW,ttZ,ttH",
        'weight': 1.,
        'plot': True,
        },
    'VVV' : {
        'order' : 11,
        'files' : [ x.filename() for x in era if x.name() == 'VVV' and x.active() ],
        'fillcolor' : 46,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "WWW,WWZ,ZZZ",
        'weight': 1.,
        'plot': True,
        },
    'WWJJ' : {
        'order' : 9,
        'files' : [ x.filename() for x in era if x.name() == 'WWJJ' and x.active() ],
        'fillcolor' : 8,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W+W+,W-W-",
        'weight': 1.,
        'plot': True,
        },
    'Vg' : {
        'order' : 6,
        'files' : [ x.filename() for x in era if x.name() == 'Vg' and x.active() ],
        'fillcolor' : 42,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W#gamma,Z#gamma",
        'weight': 1.,
        'plot': True,
        },
    'QCD' : {
        'order' : 6,
        'files' : [ x.filename() for x in era if x.name() == 'QCD' and x.active() ],
        'fillcolor' : 921,
        'fillstyle' : 1001,
        'linecolor' : 921,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "multijet",
        'weight': 1.,
        'plot': True,
    },
    'tZq' : {
        'order' : 12,
        'files' : [ x.filename() for x in era if x.name() == 'tZq' and x.active() ],
        'fillcolor' : 30,
        'fillstyle' : 1001,
        'linecolor' : 602,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "tZq",
        'weight': 1.,
        'plot': True,
    },
    ## Signal
    'wmhww': {
        'order' : 0,
        'files' : [ x.filename() for x in era if x.name() == 'wmhww' and x.active() ],
        'fillcolor' : 2,
        'fillstyle' : 3003,
        'linecolor' : 2,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W^{-}H(l^{-}l^{-}#tilde{#nu}#tilde{#nu}jj)",
        'weight': 1.,
        'plot': True,
        },
    'wphww': {
        'order' : 0,
        'files' : [ x.filename() for x in era if x.name() == 'wphww' and x.active() ],
        'fillcolor' : 4,
        'fillstyle' : 3003,
        'linecolor' : 4,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W^{+}H(l^{+}l^{+}#nu#nujj)",
        'weight': 1.,
        'plot': True,
        },
    'whww': {
        'order' : 0,
        'files' : [ x.filename() for x in era if x.name() == 'whww' and x.active() ],
        'fillcolor' : 2,
        'fillstyle' : 3003,
        'linecolor' : 2,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "W^{#pm}H(l^{#pm}l^{#pm}#tilde{#nu}#tilde{#nu}jj)",
        'weight': 1.,
        'plot': True,
        },
    'WHWW' : {
        'order' : 1001,
        'files' : [ x.filename() for x in era if x.name() == 'WHWW' and x.active() ],
        'fillcolor' : 5,
        'fillstyle' : 3003,
        'linecolor' : 5,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "HW^{#pm}J_HToWW_M125",
        'weight': 1.,
        'plot': True,
        },
    'WHWWm' : {
        'order' : 1001,
        'files' : [ x.filename() for x in era if x.name() == 'WHWWm' and x.active() ],
        'fillcolor' : 5,
        'fillstyle' : 3003,
        'linecolor' : 5,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "WmHWW",
        'weight': 1.,
        'plot': True,
        },
    'WHWWp' : {
        'order' : 1001,
        'files' : [ x.filename() for x in era if x.name() == 'WHWWp' and x.active() ],
        'fillcolor' : 6,
        'fillstyle' : 3003,
        'linecolor' : 6,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "WpHWW",
        'weight': 1.,
        'plot': True,
        },
    'VH': {
        'order' : 0,
        'files' : [ x.filename() for x in era if x.name() == 'VH' and x.active() ],
        'fillcolor' : 3,
        'fillstyle' : 3003,
        'linecolor' : 3,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "VH",
        'weight': 1.,
        'plot': True,
        },
    # Dummy entry for background sum
    'BkgSum' : {
        'order' : 0,
        'files' : [],
        'fillcolor' : 1,
        'fillstyle' : 3003,
        'linecolor' : 1,
        'linewidth' : 2,
        'linestyle' : 1,
        'label' : "MC stat.",
        'weight': 1.,
        'plot': True,
    },
}

#latino={}
#for tag in Run2_17_nanov2_la:
#    latino["%s"%tag.name()]={}
#    latino["%s"%tag.name()]['files']=[ x for x in os.listdir("/lustre/cmswork/hoh/NANO/SSLep/nanoskim/final/CMSSW_9_4_13/src/PhysicsTools/NanoAODTools/latino-skim-v4-merge/") \
#                                           if '%s'%tag.filename() in x ]

#samples = dict(samples, **latino)
