import FWCore.ParameterSet.Config as cms

from TreeMaker.WeightProducer.MCSample import MCSample

# semivisible jet signals
SVJsamples = [
    MCSample(
        "step4_MINIAOD_2016_mZprime-3000_mDark-20_rinv-0.3_alpha-0.2_n-1000",
        "ProductionV3", "", "Constant", 48974),
    MCSample("step4_MINIAOD_mZprime-3000_mDark-20_rinv-0.3_alpha-0.2_n-1000",
             "ProductionV3", "", "Constant", 49414),
    MCSample("step4_MINIAOD_mZprime-3000_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 49206),
    MCSample("step4_MINIAOD_mZprime-1000_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 49204),
    MCSample("step4_MINIAOD_mZprime-1500_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 48603),
    MCSample("step4_MINIAOD_mZprime-2000_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 49156),
    MCSample("step4_MINIAOD_mZprime-2500_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 48821),
    MCSample("step4_MINIAOD_mZprime-3500_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 48974),
    MCSample("step4_MINIAOD_mZprime-4000_mDark-20_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 48978),
    MCSample("step4_MINIAOD_mZprime-3000_mDark-5_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 49194),
    MCSample("step4_MINIAOD_mZprime-3000_mDark-50_rinv-0.3_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 48693),
    MCSample("step4_MINIAOD_mZprime-3000_mDark-20_rinv-0_alpha-peak_n-1000",
             "ProductionV3", "", "Constant", 98200),
Beispiel #2
0
def main(args):
    # Read parameters
    parser = OptionParser()
    parser.add_option(
        "-d",
        "--dict",
        dest="dict",
        default="",
        help="check for samples listed in this dict (default = %default)")
    parser.add_option(
        "-p",
        "--py",
        dest="py",
        default=False,
        action="store_true",
        help="generate python w/ list of files (default = %default)")
    parser.add_option(
        "-w",
        "--wp",
        dest="wp",
        default=False,
        action="store_true",
        help="generate WeightProducer lines (default = %default)")
    parser.add_option(
        "-s",
        "--se",
        dest="se",
        default=False,
        action="store_true",
        help="make list of sites with 100% hosting (default = %default)")
    parser.add_option(
        "-u",
        "--use-full-name",
        dest="fn",
        default=False,
        action="store_true",
        help=
        "use the full name of the dataset rather than just the first part (default = %default)"
    )
    parser.add_option(
        "-o",
        "--output-folder",
        dest="of",
        default="./",
        help="put the output files in the specified folder (default = %default)"
    )
    (options, args) = parser.parse_args(args)

    dictname = options.dict.replace(".py", "")
    flist = __import__(dictname).flist
    ofolder = options.of
    if ofolder[-1] != "/": ofolder += "/"
    if not os.path.isdir(ofolder):
        os.mkdir(ofolder)
    makepy = options.py
    makewp = options.wp
    makese = options.se
    makefn = options.fn
    if not makepy and not makewp and not makese:
        parser.error("No operations selected!")

    # interface with DBS
    dbs3api = DbsApi("https://cmsweb.cern.ch/dbs/prod/global/DBSReader")

    # format for dict entries:
    #                                                data: [True,  ['sample'] , []]
    #                                                  MC: [False, ['sample'] , []]
    #                               MC w/ extended sample: [False, ['sample','sample_ext'] , []]
    #                   MC w/ negative weights (amcatnlo): [False, ['sample'] , [neff]]
    # MC w/ negative weights (amcatnlo) + extended sample: [False, ['sample','sample_ext'] , [neff, neff_ext]]

    if makewp:
        wname = "weights_" + dictname + ".txt"
        wfile = open(ofolder + wname, 'w')

    if makese:
        sname = "sites_" + dictname + ".txt"
        sfile = open(ofolder + sname, 'w')

    for fitem in flist:
        is_data = fitem[0] == 0
        wrong_pu = fitem[0] == 2
        ff = fitem[1]
        x = fitem[2]
        nevents_all = []
        for f in ff:  # in case of extended samples
            print f

            # get sample name
            if makepy:
                if makefn:
                    oname = f.replace('/', '_')[1:]
                else:
                    oname = f.split('/')[1]
                    # check for extended sample
                    extcheck = re.search("ext[0-9]", f.split('/')[2])
                    if not extcheck == None and len(extcheck.group(0)) > 0:
                        oname = oname + "_" + extcheck.group(0)

                # make python file with preamble
                pfile = open(ofolder + oname + "_cff.py", 'w')
                pfile.write("import FWCore.ParameterSet.Config as cms\n\n")
                pfile.write(
                    "maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )\n"
                )
                pfile.write("readFiles = cms.untracked.vstring()\n")
                pfile.write("secFiles = cms.untracked.vstring()\n")
                pfile.write(
                    "source = cms.Source (\"PoolSource\",fileNames = readFiles, secondaryFileNames = secFiles)\n"
                )

            # get list of hosted files using PhEDEx API
            filelist = set()
            sitelist = defaultdict(int)
            url = 'https://cmsweb.cern.ch/phedex/datasvc/json/prod/filereplicas?dataset=' + f
            jstr = urllib2.urlopen(url).read()
            jstr = jstr.replace("\n", " ")
            result = json.loads(jstr)
            for block in result['phedex']['block']:
                for item in block['file']:
                    filelist.add(item['name'])
                    if makese:
                        for replica in item['replica']:
                            site = replica['node']
                            addr = replica['se']
                            # safety checks
                            if site is None: continue
                            if addr is None: addr = ""
                            ## if (site,addr) not in sitelist.keys(): sitelist[(site,addr)] = 0
                            sitelist[(site, addr)] += 1

            # get dataset info - detail only needed in makewp case
            nevents = 0
            if makewp:
                fileArrays = dbs3api.listFileArray(dataset=f, detail=makewp)
                for fileArray in fileArrays:
                    if fileArray["logical_file_name"] in filelist:
                        nevents += fileArray["event_count"]
                nevents_all.append(nevents)

            # check for sites with 100% dataset presence (based on PhEDEx)
            # refs:
            # https://github.com/dmwm/DAS/blob/master/src/python/DAS/services/combined/combined_service.py
            # https://github.com/gutsche/scripts/blob/master/PhEDEx/checkLocation.py
            if makese:
                # get total number of expected files
                nfiles_tot = len(filelist)
                # calculate dataset fraction (presence) in % and check for completion
                highest_percent = 0
                for site, addr in sitelist:
                    this_percent = float(
                        sitelist[(site, addr)]) / float(nfiles_tot) * 100
                    sitelist[(site, addr)] = this_percent
                    if this_percent > highest_percent:
                        highest_percent = this_percent

                sfile.write(f + "\n")
                if highest_percent < 100:
                    sfile.write(
                        "  !!! No site has complete dataset !!! ( Highest: " +
                        str(highest_percent) + "% )\n")
                for site, addr in sorted(sitelist):
                    this_percent = sitelist[(site, addr)]
                    if this_percent == highest_percent:
                        sfile.write("  " + site + " (" + addr + ")\n")

            if makepy:
                #sort list of files for consistency
                filesort = sorted(filelist)
                counter = 0
                #split into chunks of 255
                for lfn in filesort:
                    if counter == 0: pfile.write("readFiles.extend( [\n")
                    pfile.write("       '" + lfn + "',\n")
                    if counter == 254 or lfn == filesort[-1]:
                        pfile.write("] )\n")
                        counter = 0
                    else:
                        counter += 1

        #only do weightproducer stuff for MC
        if makewp and is_data == False:
            nevents = nevents_all[0]
            neff = 0
            if len(x) > 0: neff = x[0]

            #handle combining extended samples
            if len(ff) > 1:
                neff = sum(x[0:])
                nevents = sum(nevents_all)

            for i, f in enumerate(ff):
                #make line for weightproducer
                line = (" " * 8) + repr(
                    MCSample(
                        f.split('/')[1], "-".join(
                            f.split('/')[2].split('-')[1:3]),
                        f.split('/')[2].split('-')[0], "Constant", nevents,
                        wrong_pu, neff if neff > 0 else None)) + ","
                if neff > 0:
                    if len(ff) > 1:
                        line = line + " # subtotal = " + str(
                            x[i]) + ", straight subtotal = " + str(
                                nevents_all[i]) + "\n"
                    else:
                        line = line + "\n"
                else:
                    if len(ff) > 1:
                        line = line + " # subtotal = " + str(
                            nevents_all[i]) + "\n"
                    else:
                        line = line + "\n"
                wfile.write(line)
Beispiel #3
0
import FWCore.ParameterSet.Config as cms

from TreeMaker.WeightProducer.MCSample import MCSample

# 13 TeV miniAODv2 samples - Summer16
Summer16samples = [
    # backgrounds
    # NB: amcatnlo samples have negative weight events, so NumberEvts = # positive - # negative
    MCSample("TTJets_TuneCUETP8M1_13TeV-madgraphMLM-pythia8",
             "PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1",
             "RunIISummer16MiniAODv2", "Constant", 10139950),
    # ttbar single lep & dilep
    MCSample("TTJets_SingleLeptFromT_TuneCUETP8M1_13TeV-madgraphMLM-pythia8",
             "PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1",
             "RunIISummer16MiniAODv2", "Constant",
             61973977),  # subtotal = 11957043
    MCSample("TTJets_SingleLeptFromT_TuneCUETP8M1_13TeV-madgraphMLM-pythia8",
             "PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6_ext1-v1",
             "RunIISummer16MiniAODv2", "Constant",
             61973977),  # subtotal = 50016934
    MCSample(
        "TTJets_SingleLeptFromTbar_TuneCUETP8M1_13TeV-madgraphMLM-pythia8",
        "PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1",
        "RunIISummer16MiniAODv2", "Constant", 60210394),  # subtotal = 11944041
    MCSample(
        "TTJets_SingleLeptFromTbar_TuneCUETP8M1_13TeV-madgraphMLM-pythia8",
        "PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6_ext1-v1",
        "RunIISummer16MiniAODv2", "Constant", 60210394),  # subtotal = 48266353
    MCSample("TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8",
             "PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1",
             "RunIISummer16MiniAODv2", "Constant",
Beispiel #4
0
import FWCore.ParameterSet.Config as cms

from TreeMaker.WeightProducer.MCSample import MCSample

# 13 TeV miniAODv2 samples - Fall17
Fall17samples = [
    # NB: amcatnlo samples have negative weight events, so NumberEvts = # positive - # negative
    # NLO powheg
    MCSample('TTJets_TuneCP5_13TeV-madgraphMLM-pythia8',
             'PU2017_12Apr2018_94X_mc2017_realistic_v14-v1',
             'RunIIFall17MiniAODv2', 'Constant', 8026103, False, 8016963),
    # ttbar single lep & dilep xsecs scaled by PDG BR, assume t=tbar (hadronic: 377.96)
    MCSample('TTJets_SingleLeptFromT_TuneCP5_13TeV-madgraphMLM-pythia8',
             'PU2017_12Apr2018_94X_mc2017_realistic_v14-v1',
             'RunIIFall17MiniAODv2', 'Constant', 61761347, True, 61692445),
    MCSample('TTJets_SingleLeptFromT_TuneCP2_13TeV-madgraphMLM-pythia8',
             'PUFall17Fast_lhe_94X_mc2017_realistic_v15-v1',
             'RunIIFall17MiniAODv2', 'Constant', 4391055, False),
    MCSample('TTJets_SingleLeptFromTbar_TuneCP5_13TeV-madgraphMLM-pythia8',
             'PU2017_12Apr2018_94X_mc2017_realistic_v14-v1',
             'RunIIFall17MiniAODv2', 'Constant', 56705550, False, 56643562),
    MCSample('TTJets_SingleLeptFromTbar_TuneCP2_13TeV-madgraphMLM-pythia8',
             'PUFall17Fast_lhe_94X_mc2017_realistic_v15-v1',
             'RunIIFall17MiniAODv2', 'Constant', 4361067, False),
    MCSample('TTJets_DiLept_TuneCP5_13TeV-madgraphMLM-pythia8',
             'PU2017_12Apr2018_94X_mc2017_realistic_v14-v1',
             'RunIIFall17MiniAODv2', 'Constant', 28380110, False, 28349068),
    MCSample(
        'TTJets_SingleLeptFromT_genMET-150_TuneCP5_13TeV-madgraphMLM-pythia8',
        'PU2017_12Apr2018_94X_mc2017_realistic_v14-v1', 'RunIIFall17MiniAODv2',
        'Constant', 14368494, False, 14334094),
import FWCore.ParameterSet.Config as cms
from TreeMaker.WeightProducer.MCSample import MCSample

EMJsamples = [
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-1_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-0p56_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-0p37_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-0p25_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-0p21_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-0p18_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1000_mDark-20_kappa-0p12_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1200_mDark-20_kappa-1_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1200_mDark-20_kappa-0p45_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1200_mDark-20_kappa-0p3_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1200_mDark-20_kappa-0p26_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1200_mDark-20_kappa-0p21_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1200_mDark-20_kappa-0p14_aligned-down",
             "ProductionV1", "", "Constant", 5000),
    MCSample("step4_MINIAOD_mMed-1600_mDark-20_kappa-1_aligned-down",
Beispiel #6
0
import FWCore.ParameterSet.Config as cms

from TreeMaker.WeightProducer.MCSample import MCSample

# 13 TeV miniAOD samples - Autumn18
Autumn18samples = [
	# NB: amcatnlo samples have negative weight events, so NumberEvts = # positive - # negative
	MCSample('TTJets_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 10244307, False, 10234409),
	MCSample('TTJets_SingleLeptFromTbar_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 59929205, False, 59872080),
	MCSample('TTJets_SingleLeptFromT_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 57259880, False, 57205136),
	MCSample('TTJets_DiLept_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 28701360, False, 28674428),
	MCSample('TTJets_SingleLeptFromT_genMET-80_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 84200008, False, 84099728),
	MCSample('TTJets_SingleLeptFromTbar_genMET-80_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 79463720, False, 79369120),
	MCSample('TTJets_DiLept_genMET-80_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 58442000, False, 58374896),
	MCSample('TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 14149394, False, 14065202),
	MCSample('TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 10372802, False, 10282774),
	MCSample('TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 2779427, False, 2735863),
	MCSample('TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 1451104, False, 1376490),
	MCSample('QCD_Pt_80to120_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 29535000, False),
	MCSample('QCD_Pt_120to170_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 25255000, False),
	MCSample('QCD_Pt_170to300_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 29710000, False),
	MCSample('QCD_Pt_300to470_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 41744000, False),
	MCSample('QCD_Pt_470to600_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 42459973, False), # subtotal = 17712000, straight subtotal = 17712000
	MCSample('QCD_Pt_470to600_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15_ext1-v2', 'RunIIAutumn18MiniAOD', 'Constant', 42459973, False), # subtotal = 24747973, straight subtotal = 24747973
	MCSample('QCD_Pt_600to800_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 64061000, False),
	MCSample('QCD_Pt_800to1000_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15_ext1-v2', 'RunIIAutumn18MiniAOD', 'Constant', 37598000, False),
	MCSample('QCD_Pt_1000to1400_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 18485000, False),
	MCSample('QCD_Pt_1400to1800_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 6928000, False), # subtotal = 2160000, straight subtotal = 2160000
	MCSample('QCD_Pt_1400to1800_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15_ext1-v2', 'RunIIAutumn18MiniAOD', 'Constant', 6928000, False), # subtotal = 4768000, straight subtotal = 4768000
	MCSample('QCD_Pt_1800to2400_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD', 'Constant', 4017800, False), # subtotal = 1445800, straight subtotal = 1445800
	MCSample('QCD_Pt_1800to2400_TuneCP5_13TeV_pythia8', '102X_upgrade2018_realistic_v15_ext1-v2', 'RunIIAutumn18MiniAOD', 'Constant', 4017800, False), # subtotal = 2572000, straight subtotal = 2572000
import FWCore.ParameterSet.Config as cms

from TreeMaker.WeightProducer.MCSample import MCSample

# 13 TeV miniAOD samples - Autumn18
Autumn18samples = [
    # NB: amcatnlo samples have negative weight events, so NumberEvts = # positive - # negative
    MCSample('TTJets_TuneCP5_13TeV-madgraphMLM-pythia8',
             '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
             'Constant', 10244307, False, 10234409),
    MCSample('TTJets_SingleLeptFromTbar_TuneCP5_13TeV-madgraphMLM-pythia8',
             '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
             'Constant', 59929205, False, 59872080),
    MCSample('TTJets_SingleLeptFromT_TuneCP5_13TeV-madgraphMLM-pythia8',
             '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
             'Constant', 57259880, False, 57205136),
    MCSample('TTJets_DiLept_TuneCP5_13TeV-madgraphMLM-pythia8',
             '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
             'Constant', 28701360, False, 28674428),
    MCSample(
        'TTJets_SingleLeptFromT_genMET-80_TuneCP5_13TeV-madgraphMLM-pythia8',
        '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
        'Constant', 84200008, False, 84099728),
    MCSample(
        'TTJets_SingleLeptFromTbar_genMET-80_TuneCP5_13TeV-madgraphMLM-pythia8',
        '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
        'Constant', 79463720, False, 79369120),
    MCSample('TTJets_DiLept_genMET-80_TuneCP5_13TeV-madgraphMLM-pythia8',
             '102X_upgrade2018_realistic_v15-v1', 'RunIIAutumn18MiniAOD',
             'Constant', 58442000, False, 58374896),
    MCSample('TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8',