def main(): parser = argparse.ArgumentParser( description= 'Data writer for Zprime -> ll analysis interpretation in combine') parser.add_argument("--expected", action="store_true", default=False, help="write datacards for expected limit mass binning") parser.add_argument("-i", "--inject", action="store_true", default=False, help="inject signal") parser.add_argument("-c", "--chan", dest="chan", default="", help="name of the channel to use") parser.add_argument("-o", "--options", dest="config", default="", help="name of config file") parser.add_argument("-t", "--tag", dest="tag", default="", help="tag") parser.add_argument("-m", "--mass", dest="mass", default=2000, help="tag") parser.add_argument("-s", "--signif", action="store_true", default=False, help="write card for significances") parser.add_argument( "--workDir", dest="workDir", default="", help="tells batch jobs where to put the datacards. Not for human use!") args = parser.parse_args() tag = args.tag if not args.tag == "": tag = "_" + args.tag import glob from ROOT import gROOT for f in glob.glob("userfuncs/*.cxx"): gROOT.ProcessLine(".L " + f + "+") configName = "scanConfiguration_%s" % args.config config = __import__(configName) moduleName = "channelConfig_%s" % args.chan module = __import__(moduleName) from createInputs import createSingleBinCI from tools import getCardDir cardDir = getCardDir(args, config) if not os.path.exists(cardDir): os.makedirs(cardDir) lambdas = config.lambdas nPoints = len(config.lambdas) * len(config.interferences) index = 0 for Lambda in config.lambdas: for interference in config.interferences: name = "%s/%s_%d_%s" % (cardDir, args.chan, Lambda, interference) if args.inject or "toy" in tag: yields = createSingleBinCI(Lambda, interference, name, args.chan, args.config, args.mass, dataFile=injectedFile) else: yields = createSingleBinCI(Lambda, interference, name, args.chan, args.config, args.mass) backgrounds = config.backgrounds nBkg = len(backgrounds) channelDict = {} channelDict["date"] = time.strftime("%d/%m/%Y") channelDict["time"] = time.strftime("%H:%M:%S") #channelDict["hash"] = get_git_revision_hash() channelDict["bin"] = args.chan channelDict["nBkgs"] = nBkg scale = False res = False ID = False PDF = False channelDict["data"] = yields["data"] channelDict["channels"] = getChannelBlock(backgrounds, yields, 1, args.chan) uncertBlock = "" uncerts = module.provideUncertaintiesCI(Lambda) for uncert in config.systematics: uncertBlock += getUncert(uncert, uncerts[uncert], backgrounds, Lambda, args.chan, config.correlate, yields, args.signif) channelDict["systs"] = uncertBlock writeCard(cardTemplate % channelDict, name) printProgress(index + 1, nPoints, prefix='Progress:', suffix='Complete', barLength=50) index += 1
def main(): parser = argparse.ArgumentParser( description= 'Data writer for Zprime -> ll analysis interpretation in combine') parser.add_argument("-b", "--binned", action="store_true", default=False, help="use binned dataset") parser.add_argument("--expected", action="store_true", default=False, help="write datacards for expected limit mass binning") parser.add_argument("-i", "--inject", action="store_true", default=False, help="inject signal") parser.add_argument("-c", "--chan", dest="chan", default="", help="name of the channel to use") parser.add_argument("-o", "--options", dest="config", default="", help="name of config file") parser.add_argument("-m", "--mass", dest="mass", default=-1, type=int, help="mass point") parser.add_argument("-t", "--tag", dest="tag", default="", help="tag") parser.add_argument("-s", "--signif", action="store_true", default=False, help="write card for significances") parser.add_argument("--DM", action="store_true", default=False, help="write cards for DM interpretation") args = parser.parse_args() tag = args.tag if not args.tag == "": tag = "_" + args.tag import glob from ROOT import gROOT for f in glob.glob("userfuncs/*.cxx"): gROOT.ProcessLine(".L " + f + "+") configName = "scanConfiguration_%s" % args.config config = __import__(configName) moduleName = "channelConfig_%s" % args.chan module = __import__(moduleName) from createInputs import createWS, createHistograms, createSignalDataset from tools import getCardDir cardDir = getCardDir(args, config) if "toy" in tag: injectedFile = "input/%s%s.txt" % (args.chan, tag) if not os.path.isfile(injectedFile): print "dataset file %s does not yet exist. Will generate a dataset to use" % injectedFile name = "input/%s" % (args.chan) createSignalDataset(config.signalInjection["mass"], name, args.chan, config.signalInjection["width"], 0, config.signalInjection["CB"], tag=tag) elif args.inject: if config.signalInjection["CB"]: injectedFile = "input/%s_%d_%.3f_%d_CB.txt" % ( args.chan, config.signalInjection["mass"], config.signalInjection["width"], config.signalInjection["nEvents"]) else: injectedFile = "input/%s_%d_%.3f_%d.txt" % ( args.chan, config.signalInjection["mass"], config.signalInjection["width"], config.signalInjection["nEvents"]) if not os.path.isfile(injectedFile): print "dataset file %s does not yet exist. Will generate a dataset to use" % injectedFile name = "input/%s" % (args.chan) createSignalDataset(config.signalInjection["mass"], name, args.chan, config.signalInjection["width"], config.signalInjection["nEvents"], config.signalInjection["CB"]) if not os.path.exists(cardDir): os.makedirs(cardDir) if args.mass > 0: masses = [[5, args.mass, args.mass]] else: masses = config.masses if args.expected: masses = config.massesExp nMasses = 0 for massRange in masses: mass = massRange[1] while mass <= massRange[2]: nMasses += 1 mass += massRange[0] i = 1 for massRange in masses: mass = massRange[1] while mass <= massRange[2]: if args.binned: name = "%s/%s_%d_binned" % (cardDir, args.chan, mass) if args.inject or "toy" in tag: bkgYields = [ createHistograms(mass, 100, name, args.chan, config.width, config.correlate, config.binWidth, dataFile=injectedFile, CB=config.CB) ] else: bkgYields = [ createHistograms(mass, 100, name, args.chan, config.width, config.correlate, config.binWidth, CB=config.CB) ] else: name = "%s/%s_%d" % (cardDir, args.chan, mass) if args.inject or "toy" in tag: bkgYields = [ createWS(mass, 100, name, args.chan, config.width, config.correlate, dataFile=injectedFile, CB=config.CB) ] else: bkgYields = [ createWS(mass, 100, name, args.chan, config.width, config.correlate, CB=config.CB) ] if args.DM: signalScale = module.provideSignalScaling(mass, DM=True) else: signalScale = module.provideSignalScaling(mass) * 1e-7 nBkg = 1 # only one source of background supported at the moment channelDict = {} channelDict["date"] = time.strftime("%d/%m/%Y") channelDict["time"] = time.strftime("%H:%M:%S") #channelDict["hash"] = get_git_revision_hash() channelDict["bin"] = args.chan channelDict["nBkgs"] = nBkg if nBkg == 1: channelDict["bkgShapes"] = getBackgroundShapes( args.binned, "%s.root" % name, args.chan, 0) else: channelDict["bkgShapes"] = "" for i in range(1, nBkg + 1): channelDict["bkgShapes"] += getBackgroundShapes( args.binned, "%s.root" % nam, eargs.chan, i) if i < nBkg: channelDict["bkgShapes"] += "\n" scale = False if "massScale" in config.systematics: scale = True channelDict["sigShape"] = getSignalShape(args.binned, "%s.root" % name, args.chan, scale) channelDict["data"] = getDataset(args.binned, "%s.root" % name, args.chan) channelDict["channels"] = getChannelBlock(nBkg, bkgYields, signalScale, args.chan) uncertBlock = "" uncerts = module.provideUncertainties(mass) for uncert in config.systematics: uncertBlock += getUncert(uncert, uncerts[uncert], nBkg, mass, args.chan, config.correlate, args.binned, bkgYields, args.signif) channelDict["systs"] = uncertBlock writeCard(cardTemplate % channelDict, name) printProgress(i, nMasses, prefix='Progress:', suffix='Complete', barLength=50) i += 1 mass += massRange[0]
help="calculate limits for spin2 resonances") args = parser.parse_args() if args.LEE: args.signif = True args.submit = True configName = "scanConfiguration_%s" % args.config config = __import__(configName) tag = args.tag if not args.tag == "": args.tag = "_" + args.tag from tools import getCardDir, getOutDir cardDir = getCardDir(args, config) if args.CI: summarizeConfigCI(config, args, cardDir) else: summarizeConfig(config, args, cardDir) if args.crab: submitLimitsToCrab(args, config, cardDir) if (args.redo or args.write) and not args.LEE and not args.CI: createInputs(args, config, cardDir) elif (args.redo or args.write) and not args.LEE and args.CI: createInputsCI(args, config, cardDir) if args.write: sys.exit()