groupJobs=5 # used in make_helicity_cards.py (options, args) = parser.parse_args() if len(args) < 2: parser.print_usage() quit() channel = args[1] ybinfile = args[0]+'/binningYW.txt' ybinfile = open(ybinfile, 'r') ybins = eval(ybinfile.read()) ybinfile.close() if options.fitresult: print "Scaling the templates to the post-fit results in: ",options.fitresult valuesAndErrors = utilities.getFromHessian(options.fitresult) allNuisances = utilities.getFromHessian(options.fitresult,keepGen=True) outname = options.outdir if not os.path.exists(outname): os.system("mkdir -p "+outname) if os.path.exists("/afs/cern.ch"): os.system("cp /afs/cern.ch/user/g/gpetrucc/php/index.php "+outname) for charge in ['plus','minus']: shapesfile = "{indir}/W{flav}_{ch}_shapes.root".format(indir=args[0],flav=channel,ch=charge) infile = ROOT.TFile(shapesfile, 'read') print "" print "==> RUNNING FOR CHARGE ",charge outfile_templates = options.outfile_templates if outfile_templates.endswith(".root"):
if len(options.nuis) == 0 and len(options.nuisgroups) == 0: print "Will plot the impact for all the single nuisances. It may be a big matrix" nuis_regexps = ['.*'] else: nuis_regexps = list(options.nuis.split(',')) if len( options.nuis) else list(options.nuisgroups.split(',')) print "Filtering nuisances or nuisance groups with the following regex: ", nuis_regexps if len(options.pois) == 0: pois_regexps = ['.*'] else: pois_regexps = list(options.pois.split(',')) hessfile = ROOT.TFile(args[0], 'read') valuesAndErrors = utilities.getFromHessian(args[0]) group = 'group_' if len(options.nuisgroups) else '' if options.target == 'xsec': target = 'pmaskedexp' elif options.target == 'xsecnorm': target = 'pmaskedexpnorm' elif options.target == 'unpolxsec': target = 'sumpois' elif options.target == 'asym': target = 'chargepois' elif options.target == 'unpolasym': target = 'chargemetapois' elif options.target == 'A0' or options.target == 'A4': target = 'polpois' elif options.target == 'etaptasym': target = 'chargepois' elif options.target == 'etaxsec': target = 'sumpois' elif options.target == 'etaxsecnorm': target = 'sumpoisnorm' elif options.target == 'etaasym': target = 'chargemetapois' else: target = 'mu' # patch for diff.xsec, because I usually pass pois as regular expressions matching the charge
else: ybinfile = os.path.dirname(os.path.abspath(options.infile))+'/binningYW.txt' ## get the central values and uncertainties depending on the type given: ## if --type=toys , we expect a toyfile ## if --type=scans , we expect a scan directory ## if --type=hessian, we expect a hessian file if options.type == 'toys': valuesAndErrors = utilities.getFromToys(options.infile) elif options.type == 'scans': valuesAndErrors = utilities.getFromScans(options.infile) elif options.type == 'hessian': valuesAndErrors = utilities.getFromHessian(options.infile) else: print 'ERROR: none of your types is supported. specify either "toys", "scans", or "hessian"' sys.exit() channel = 'mu' if any(re.match(param,'.*_mu_Ybin_.*') for param in valuesAndErrors.keys()) else 'el' print "From the list of parameters it seems that you are plotting results for channel ",channel ybinfile = open(ybinfile, 'r') ybins = eval(ybinfile.read()) ybinfile.close() ## calculate the bin widths for the rapidity bins ybinwidths = {} for k,v in ybins.items(): tmplist = list(abs(i - v[v.index(i)+1]) for i in v[:-1])
(options, args) = parser.parse_args() infile = options.infile os.system('mkdir -p {od}'.format(od=options.outdir)) os.system('cp ~emanuele/public/index.php {od}'.format(od=options.outdir)) #valuesPrefit = dict((k,v) for k,v in valuesAndErrorsAll.iteritems() if k.endswith('_gen')) pois_regexps = list(options.pois.split(',')) if options.type == 'toys': valuesAndErrorsAll = utilities.getFromToys(infile, keepGen=True, params=pois_regexps) elif options.type == 'hessian': valuesAndErrorsAll = utilities.getFromHessian(infile, keepGen=True) else: print 'ERROR: none of your types is supported. specify either "toys", "scans", or "hessian"' sys.exit() print 'looking for regexp match', pois_regexps valuesAndErrors = {} valuesErrors = {} valuesPrefit = {} for ppatt in pois_regexps: for (k, v) in valuesAndErrorsAll.iteritems(): if re.match(ppatt, k): if k.endswith('_gen'): valuesPrefit[ k] = v #dict((k,v) for k,v in valuesPrefit.iteritems() if re.match(ppatt.replace('$','_gen'),k))
os.system('mkdir -p {od}'.format(od=options.outdir)) os.system('cp ~emanuele/public/index.php {od}'.format(od=options.outdir)) if options.rankNuisancesBy not in ["", "pull", "sigma"]: print "Error: option -R requires pull|sigma as argument. Abort" quit() #valuesPrefit = dict((k,v) for k,v in valuesAndErrorsAll.iteritems() if k.endswith('_gen')) pois_regexps = list(options.pois.split(',')) if options.type == 'toys': valuesAndErrorsAll = utilities.getFromToys(infile, keepGen=True, params=pois_regexps) if plotObsWithExp: valuesAndErrorsAll_exp = utilities.getFromHessian( infile_exp, keepGen=True, params=pois_regexps) elif options.type == 'hessian': valuesAndErrorsAll = utilities.getFromHessian(infile, keepGen=True, params=pois_regexps) if plotObsWithExp: valuesAndErrorsAll_exp = utilities.getFromHessian( infile_exp, keepGen=True, params=pois_regexps) else: print 'ERROR: none of your types is supported. specify either "toys", "scans", or "hessian"' sys.exit() print 'looking for regexp match', pois_regexps valuesAndErrors = {} valuesErrors = {} valuesPrefit = {}
if len(options.nuis) == 0 and len(options.nuisgroups) == 0: print "Will plot the impact for all the single nuisances. It may be a big matrix" nuis_regexps = ['.*'] else: nuis_regexps = list(options.nuis.split(',')) if len( options.nuis) else list(options.nuisgroups.split(',')) print "Filtering nuisances or nuisance groups with the following regex: ", nuis_regexps if len(options.pois) == 0: pois_regexps = ['.*'] else: pois_regexps = list(options.pois.split(',')) hessfile = ROOT.TFile(args[0], 'read') valuesAndErrors = utilities.getFromHessian(args[0], params=pois_regexps) group = 'group_' if len(options.nuisgroups) else '' if options.target == 'xsec': target = 'pmaskedexp' elif options.target == 'xsecnorm': target = 'pmaskedexpnorm' elif options.target == 'unpolxsec': target = 'sumpois' elif options.target == 'unpolxsecnorm': target = 'sumpoisnorm' elif options.target == 'asym': target = 'chargepois' elif options.target == 'unpolasym': target = 'chargemetapois' elif options.target == 'A0' or options.target == 'A4': target = 'polpois' elif options.target == 'etaptasym': target = 'chargepois' elif any(options.target == x for x in ['etaxsec', 'ptxsec']): target = 'sumpois' elif any(options.target == x for x in ['etaxsecnorm', 'ptxsecnorm']): target = 'sumpoisnorm' elif any(options.target == x for x in ['etaasym', 'ptasym']):