예제 #1
0
def main():
    parser = get_arg_parser()

    parser.add_argument('--jet-type',
                        choices=['ak8', 'ak15'],
                        required=True,
                        help='Jet type: ak8, ak15')

    parser.add_argument('--channel',
                        choices=['photon', 'qcd', 'signal', 'inclusive'],
                        required=True,
                        help='Channel: photon, qcd, signal, inclusive')

    parser.add_argument(
        '--run-syst',
        action='store_true',
        default=False,
        help='Run all the systematic trees. Default: %(default)s')

    parser.add_argument('--run-data',
                        action='store_true',
                        default=False,
                        help='Run over data. Default: %(default)s')

    parser.add_argument(
        '--year',
        type=str,
        required=True,
        help=
        'Year: 2016, 2017, 2018, or comma separated list e.g., `2016,2017,2018`'
    )

    parser.add_argument(
        '--sample-dir',
        type=str,
        default='samples',
        help='Directory of the sample list files. Default: %(default)s')

    args = parser.parse_args()

    if not (args.post or args.add_weight or args.merge):
        tar_cmssw(args.tarball_suffix)

    if ',' in args.year:
        years = [int(y) for y in args.year.split(',') if y]
        for year in years:
            for cat in ['data', 'mc']:
                opts = copy.deepcopy(args)
                if cat == 'data':
                    opts.run_data = True
                    opts.nfiles_per_job *= 2
                opts.inputdir = os.path.join(
                    opts.inputdir.replace('_YEAR_', str(year)), cat)
                opts.year = year
                print(opts.inputdir, opts.year, opts.channel,
                      'data' if opts.run_data else 'mc',
                      'syst' if opts.run_syst else '')
                _process(opts)
    else:
        _process(args)
예제 #2
0
def main():
    parser = get_arg_parser()

    parser.add_argument('--option',
                        type=str,
                        required=True,
                        help='Selection option')

    parser.add_argument(
        '--run-syst',
        action='store_true',
        default=False,
        help='Run all the systematic trees. Default: %(default)s')

    parser.add_argument('--run-data',
                        action='store_true',
                        default=False,
                        help='Run over data. Default: %(default)s')

    parser.add_argument('--run-signal',
                        action='store_true',
                        default=False,
                        help='Run over signal. Default: %(default)s')

    parser.add_argument(
        '--year',
        type=str,
        required=True,
        help=
        'Year: 2016, 2017, 2018, or comma separated list e.g., `2016,2017,2018`'
    )

    parser.add_argument(
        '--sample-dir',
        type=str,
        default='samples',
        help='Directory of the sample list files. Default: %(default)s')

    parser.add_argument('--run-mass-regression',
                        action='store_true',
                        default=True,
                        help='Run mass regression. Default: %(default)s')

    args = parser.parse_args()
    years = args.year.split(',')
    categories = ['data' if args.run_data else 'mc']

    for year in years:
        for cat in categories:
            opts = copy.deepcopy(args)
            if cat == 'data':
                opts.run_data = True
                opts.nfiles_per_job *= 2
            opts.year = year
            logging.info('year=%s, cat=%s, syst=%s', opts.year,
                         'data' if opts.run_data else 'mc',
                         'syst' if opts.run_syst else 'none')
            _process(opts)
예제 #3
0
def main():
    parser = get_arg_parser()

    parser.add_argument('--jet-type',
                        choices=['ak8', 'ak15'],
                        required=True,
                        help='Jet type: ak8, ak15')

    parser.add_argument(
        '--channel',
        type=str,
        required=True,
        help=
        'Channel: photon, qcd, muon, diboson, signal, inclusive, or comma separated list e.g., `qcd,photon`'
    )

    parser.add_argument(
        '--sfbdt',
        type=float,
        default=0.5,
        help=
        'sfBDT cut, applies only to `qcd` and `photon` channels. Default: %(default)s'
    )

    parser.add_argument(
        '--run-syst',
        action='store_true',
        default=False,
        help='Run all the systematic trees. Default: %(default)s')

    parser.add_argument('--run-data',
                        action='store_true',
                        default=False,
                        help='Run over data. Default: %(default)s')

    parser.add_argument(
        '--year',
        type=str,
        required=True,
        help=
        'Year: 2016, 2017, 2018, or comma separated list e.g., `2016,2017,2018`'
    )

    parser.add_argument(
        '--sample-dir',
        type=str,
        default='samples',
        help='Directory of the sample list files. Default: %(default)s')

    parser.add_argument('--run-tagger',
                        action='store_true',
                        default=False,
                        help='Run tagger. Default: %(default)s')

    parser.add_argument('--run-mass-regression',
                        action='store_true',
                        default=False,
                        help='Run mass regression. Default: %(default)s')

    args = parser.parse_args()

    if not (args.post or args.add_weight or args.merge):
        tar_cmssw(args.tarball_suffix)

    years = args.year.split(',')
    channels = args.channel.split(',')
    categories = ['data' if args.run_data else 'mc']

    for year in years:
        for chn in channels:
            for cat in categories:
                opts = copy.deepcopy(args)
                if cat == 'data':
                    opts.run_data = True
                    opts.nfiles_per_job *= 2
                opts.inputdir = opts.inputdir.rstrip('/').replace(
                    '_YEAR_', year)
                assert (year in opts.inputdir)
                if opts.inputdir.rsplit('/', 1)[1] not in ['data', 'mc']:
                    opts.inputdir = os.path.join(opts.inputdir, cat)
                assert (opts.inputdir.endswith(cat))
                opts.year = year
                opts.channel = chn
                logging.info(
                    'inputdir=%s, year=%s, channel=%s, cat=%s, syst=%s',
                    opts.inputdir, opts.year, opts.channel,
                    'data' if opts.run_data else 'mc',
                    'syst' if opts.run_syst else 'none')
                _process(opts)
예제 #4
0
def main():
    parser = get_arg_parser()

    parser.add_argument('--channel',
                        choices=['muon', 'photon', 'qcd'],
                        required=True,
                        help='Channel: muon, photon, qcd'
                        )

    parser.add_argument('--run-syst',
                        action='store_true', default=False,
                        help='Run all the systematic trees. Default: %(default)s'
                        )

    parser.add_argument('--run-data',
                        action='store_true', default=False,
                        help='Run over data. Default: %(default)s'
                        )

    args = parser.parse_args()

    channel = args.channel
    default_config['channel'] = channel

    if not (args.post or args.add_weight or args.merge):
        tar_cmssw()

#     args.batch = True
    basename = os.path.basename(args.outputdir) + '_' + channel
    args.outputdir = os.path.join(os.path.dirname(args.outputdir), basename, 'data' if args.run_data else 'mc')
    args.jobdir = os.path.join('jobs_%s' % basename, 'data' if args.run_data else 'mc')
    args.datasets = 'samples/%s.conf' % channel
    args.cut = cut_dict[channel]

    args.imports = [('PhysicsTools.NanoHRTTools.producers.hrtSFTreeProducer', 'hrtSFTreeFromConfig')]
    if not args.run_data:
        args.imports.extend([
            ('PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer', 'puWeight'),
            ])
        if args.channel == 'muon':
            args.imports.append(('PhysicsTools.NanoHRTTools.producers.topPtWeightProducer', 'topPtWeight'))

    # data, or just nominal MC
    if args.run_data or not args.run_syst:
        cfg = copy.deepcopy(default_config)
        if args.run_data:
            cfg['data'] = True
        run(args, configs={hrt_cfgname: cfg})
        return

    # MC for syst.
    if args.run_syst:

        # nominal w/ PDF/Scale wegihts
        logging.info('Start making nominal trees with PDF/scale weights...')
        syst_name = 'LHEWeight'
        opts = copy.deepcopy(args)
        cfg = copy.deepcopy(default_config)
        opts.outputdir = os.path.join(os.path.dirname(opts.outputdir), syst_name)
        opts.jobdir = os.path.join(os.path.dirname(opts.jobdir), syst_name)
        opts.branchsel_out = 'keep_and_drop_output_LHEweights.txt'
#        opts.datasets = 'samples/%s_syst.conf' % channel
#        if not os.path.exists(opts.datasets):
#            opts.datasets = args.datasets
        run(opts, configs={hrt_cfgname: cfg})

        # JES up/down
        for variation in ['up', 'down']:
            syst_name = 'jes_%s' % variation
            logging.info('Start making %s trees...' % syst_name)
            opts = copy.deepcopy(args)
            cfg = copy.deepcopy(default_config)
            cfg['jes'] = variation
            opts.outputdir = os.path.join(os.path.dirname(opts.outputdir), syst_name)
            opts.jobdir = os.path.join(os.path.dirname(opts.jobdir), syst_name)
            run(opts, configs={hrt_cfgname: cfg})

        # JER up/down
        for variation in ['up', 'down']:
            syst_name = 'jer_%s' % variation
            logging.info('Start making %s trees...' % syst_name)
            opts = copy.deepcopy(args)
            cfg = copy.deepcopy(default_config)
            cfg['jer'] = variation
            opts.outputdir = os.path.join(os.path.dirname(opts.outputdir), syst_name)
            opts.jobdir = os.path.join(os.path.dirname(opts.jobdir), syst_name)
            run(opts, configs={hrt_cfgname: cfg})

        # MET unclustEn up/down
        for variation in ['up', 'down']:
            syst_name = 'met_%s' % variation
            logging.info('Start making %s trees...' % syst_name)
            opts = copy.deepcopy(args)
            cfg = copy.deepcopy(default_config)
            cfg['met_unclustered'] = variation
            opts.outputdir = os.path.join(os.path.dirname(opts.outputdir), syst_name)
            opts.jobdir = os.path.join(os.path.dirname(opts.jobdir), syst_name)
            run(opts, configs={hrt_cfgname: cfg})