Пример #1
0
                  dest="mass2",
                  type="int",
                  default=None,
                  help="Only run signal points with this value as second mass")
parser.add_option("--allowoverflow",
                  dest="allowoverflow",
                  action="store_true",
                  default=False,
                  help="Allow last bin to be overflow bin")

baseBkg = "python makeShapeCardsSusy.py {MCA} {CUTS} \"{EXPR}\" \"{BINS}\" -o SR --bin {TAG} {T} --tree {TREENAME} {MCCS} {MACROS} --s2v -f -l {LUMI} --od {O} {FRIENDS} {FLAGS} {OVERFLOWCUTS}"
baseSig = "python makeShapeCardsSusy.py [[[MCA]]] [[[CUTS]]] \\\"{EXPR}\\\" \\\"{BINS}\\\" [[[SYS]]] -o SR --bin {TAG} {T} --tree {TREENAME} {MCCS} {MACROS} --s2v -f -l {LUMI} --od [[[O]]] {FRIENDS} {FLAGS} {OVERFLOWCUTS} {POSTFIX}"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
options.models = func.splitList(options.models)
mm = maker.Maker("scanmaker", baseBkg, args, options, parser.defaults)
mm.loadModels()

sl = mm.getVariable("lumi", "12.9").replace(".", "p")

combinePath = mm.getVariable("combineTool")
if options.doCheck and (not combinePath or not os.path.isdir(combinePath)
                        or combinePath[-3:] != "src"):
    combinePath = combinePath.rstrip("/")
    print "WARNING: You want to run the automatic systematics check for your datacards"
    print "but you have not given all necessary information in your configuration!"
    print "Please give the path to the 'src' directory (e.g. /usr/cheidegg/CMSSW_7_1_5/src)"
    print "of the CMSSW release where HiggsCombine is installed. You should store this"
    print "path in your configuration with the variable 'combineTool'"
    cont = raw_input(
        "Do you want to continue now without the systematics check? [y/n]\n>> "
Пример #2
0
from optparse import OptionParser
from lib import maker
from lib import functions as func

parser = OptionParser(usage="%prog cfg regions treedir outdir [options]")
parser = maker.addMakerOptions(parser)

base = "python mcDump.py --dumpFile .fdump.txt {MCA} {CUTS} {FMT} {T} --s2v --tree {TREENAME} -j 4 {MCCS} {MACROS} {FRIENDS} {PROCS} {FLAGS} &&  sort -n -k1 -k2 -k3 .fdump.txt > {O}/dump_{TAG}.txt && rm .fdump.txt"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm = maker.Maker("dumpmaker", base, args, options, parser.defaults)

friends = mm.collectFriends()
sl = mm.getVariable("lumi", "12.9").replace(".", "p")

for r in range(len(mm.regions)):
    mm.iterateRegion()

    mccs = mm.collectMCCs()
    macros = mm.collectMacros()
    flags = mm.collectFlags(["flagDumps"], False, True)
    scenario = mm.getScenario(True)

    procs = mm.getProcs()
    fmt = "'{run:1d} {lumi:9d} {evt:12d}\\t" + mm.getVariable(
        "fmt", "").replace("\\\\t", "\\t") + "'"

    for p in procs:

        output = mm.outdir + "/dump/" + scenario + "/" + sl + "fb"
        func.mkdir(output)
Пример #3
0
parser.add_option("--exclude"     , dest="exclude", type="string", action="append", default=[], help="Semicolon-separated list of samples to exclude (regexp)")
parser.add_option("--accept"      , dest="accept" , type="string", action="append", default=[], help="Semicolon-separated list of samples to accept (regexp)")
parser.add_option("--direct"      , dest="direct" , action="store_true", default=False, help="Do direct batch submission (default is doing the batch submission via prepareEventVariablesFriendTree.py) [useful for splitted fastsim masspoints]")
parser.add_option("--nosplit"     , dest="noSplit", action="store_true", default=False, help="Direct batch submission does a splitting of the jobs per nEvt. Give this flag to suppress it.")
parser.add_option("--bk"          , dest="bk"     , action="store_true", default=False, help="Bookkeeping option (stores friend tree producer and configuration)")
parser.add_option("--log"         , dest="log"    , action="store_true", default=False, help="Put log file into subdirectory 'log' in output directory")
parser.add_option("-F", "--force" , dest="force"  , action="store_true", default=False, help="Run the module even if it already exists")
parser.add_option("--finalize"    , dest="finalize", action="store_true", default=False, help="Merge the chunks and check if everything is correct")

base = "python prepareEventVariablesFriendTree.py {T} {O} --tree {TREENAME} --vector -T sf -d {SAMPLES} -m {MODULES} {FRIENDS} {ADDITIONAL}"
(options, args) = parser.parse_args()
options         = maker.splitLists(options)
options.modules = func.splitList(options.modules)
options.accept  = func.splitList(options.accept )
options.exclude = func.splitList(options.exclude)
mm              = maker.Maker("friendmaker", base, args, options)
mm.loadNEvtSample()


## loop on modules, submitting jobs
for module in mm.getFriendModules():

	mm.workdir = mm.cmssw +"/src/CMGTools/TTHAnalysis/macros"
	output     = mm.outdir +"/"+ module
	func.mkdir(output,False)
	func.mkdir(output +"/log",False)
	if options.bk: func.mkdir(output +"/ref",False)

	file     = getFriendFile(mm, module)
	requires = getFriendConn(mm, module)
	requires = filter(lambda x: x, requires)
Пример #4
0
import os
from optparse import OptionParser
from lib import maker
from lib import functions as func

parser = OptionParser(usage="%prog cfg regions treedir outdir [options]")
parser = maker.addMakerOptions(parser)
parser.add_option("--perBin"  ,  dest="perBin"  , action="store_true", default=False, help="Run every value of the bin separately.")
parser.add_option("--finalize",  dest="finalize", action="store_true", default=False, help="After running, tidy up output directory like scanmaker")

base = "python makeShapeCardsSusy.py {MCA} {CUTS} \"{EXPR}\" \"{BINS}\" {SYS} -o SR {T} --tree {TREENAME} {MCCS} {MACROS} --neg --s2v -f -l {LUMI} --od {O} {FRIENDS} {PROCS} {FLAGS}"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm      = maker.Maker("limitmaker", base, args, options, parser.defaults)

friends = mm.collectFriends()	
sl      = mm.getVariable("lumi","12.9").replace(".","p")
outDirs = []

for r in range(len(mm.regions)):
	mm.iterateRegion()

	mccs     = mm.collectMCCs  ()
	macros   = mm.collectMacros()	
	flags    = mm.collectFlags (["flagsLimits"])
	scenario = mm.getScenario(True)

	procs    = " ".join(["-p "+b for b in mm.getProcs()])
	binnings = [mm.getVariable("bins","")] if not options.perBin else func.getAllBins(mm.getVariable("bins",""))
	
	for ib,b in enumerate(binnings):
Пример #5
0
                  "--final",
                  dest="final",
                  action="store_true",
                  default=False,
                  help="Only total yield")
parser.add_option("--fom",
                  dest="fom",
                  type="string",
                  default=None,
                  help="Figure of merit (S/B, S/sqrB, S/sqrSB)")

baseAll = "python mcAnalysis.py {MCA} {CUTS} {T} --neg --s2v --tree {TREENAME} {FINAL} {MCCS} {MACROS} -l {LUMI} {FRIENDS} {PROCS} {FLAGS} {FOM} >> {O}/{FILENAME}"
baseBin = "python mcPlots.py {MCA} {CUTS} {PLOTFILE} {T} --neg --s2v --tree {TREENAME} {FINAL} {MCCS} {MACROS} -l {LUMI} --pdir {O} {FRIENDS} {PROCS} {PLOTS} {FLAGS} --perBin --print txt"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm = maker.Maker("accmaker", baseAll, args, options, parser.defaults)
if options.perBin: mm.reloadBase(baseBin)

friends = mm.collectFriends()
sl = mm.getVariable("lumi", "12.9").replace(".", "p")

for r in range(len(mm.regions)):
    mm.iterateRegion()

    scenario = mm.getScenario(True)
    mccs = mm.collectMCCs()
    macros = mm.collectMacros()
    flags = mm.collectFlags(["flagsAccs"])

    output = mm.outdir + "/acc/" + scenario + "/" + sl + "fb"
    func.mkdir(output)
Пример #6
0
    default=[],
    help=
    "Only use these samples in the skimming and ignore procs, bkgs and sigs")
parser.add_option("--allSamples",
                  dest="allSamples",
                  action="store_true",
                  default=False,
                  help="Skim all samples in the MCA")

base = "python skimTrees.py {MCA} {CUTS} {O} -P {T} --tree {TREENAME} {MCCS} {MACROS} {FRIENDS} {JSON}"
baseFriends = "python skimFTrees.py {T} {F} {O}"

(options, args) = parser.parse_args()
options = maker.splitLists(options)
options.samples = func.splitList(options.samples)
mm = maker.Maker("skimmaker", base, args, options)

## skim main tree
friends = mm.collectFriends()
mccs = mm.collectMCCs()
macros = mm.collectMacros()

for r in range(len(mm.regions)):
    mm.iterateRegion()
    mm.reloadBase(base)

    mca = makeDummyMCA(mm, options.samples, options.allSamples)

    output = mm.outdir
    func.mkdir(output)
    json = options.json if options.json else ""
Пример #7
0
parser.add_option(
    "--noSplit",
    dest="noSplit",
    action="store_true",
    default=False,
    help="Do not make jobs to run in parallel, only make one big job")

base = "python skimTrees.py {MCA} {CUTS} {O} -P {T} --tree {TREENAME} {MCCS} {MACROS} {FRIENDS} {JSON} {FLAGS}"
baseFriends = "python skimFTrees.py {T} {F} {O}"

(options, args) = parser.parse_args()
options = maker.splitLists(options)
options.samples = func.splitList(options.samples)
options.accept = func.splitList(options.accept)
options.exclude = func.splitList(options.exclude)
mm = maker.Maker("skimmaker", base, args, options, parser.defaults)

## skim main tree
friends = mm.collectFriends()
flags = " ".join(
    mm.options.flags
)  ## we do not want to have all flags, only the additional ones given here

for r in range(len(mm.regions)):
    mm.iterateRegion()
    mm.reloadBase(base)

    mccs = mm.collectMCCs()
    macros = mm.collectMacros()

    output = mm.outdir
Пример #8
0
                  action="store_true",
                  default=False,
                  help="Run the module even if it already exists")
parser.add_option("--finalize",
                  dest="finalize",
                  action="store_true",
                  default=False,
                  help="Merge the chunks and check if everything is correct")

base = "python prepareEventVariablesFriendTree.py {T} {O} --tra2 --tree {TREENAME} --vector -T sf -d {SAMPLES} -m {MODULES} {FRIENDS} {ADDITIONAL} -I CMGTools.TTHAnalysis.tools.multilepFriendTreeProducersToCleanup {FLAGS}"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
options.modules = func.splitList(options.modules)
options.accept = func.splitList(options.accept)
options.exclude = func.splitList(options.exclude)
mm = maker.Maker("friendmaker", base, args, options, parser.defaults)
mm.loadNEvtSample()

flags = mm.getOption("flags", [])

## loop on modules, submitting jobs
for module in mm.getFriendModules():

    mm.workdir = mm.cmssw + "/src/CMGTools/TTHAnalysis/macros"
    output = mm.outdir + "/" + module
    func.mkdir(output, False)
    func.mkdir(output + "/log", False)
    if options.bk: func.mkdir(output + "/ref", False)

    file = getFriendFile(mm, module)
    requires = getFriendConn(mm, module)
Пример #9
0
parser.add_option("--perBin",
                  dest="perBin",
                  action="store_true",
                  default=False,
                  help="Run every value of the bin separately.")
parser.add_option(
    "--finalize",
    dest="finalize",
    action="store_true",
    default=False,
    help="After running, tidy up output directory like scanmaker")

base = "python makeShapeCardsSusy.py {MCA} {CUTS} \"{EXPR}\" \"{BINS}\" {SYS} -o SR -P {T} --tree {TREENAME} {MCCS} {MACROS} --neg --s2v -f -l {LUMI} --od {O} {FRIENDS} {PROCS} {FLAGS}"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm = maker.Maker("limitmaker", base, args, options)

sl = str(options.lumi)

friends = mm.collectFriends()
mccs = mm.collectMCCs()
macros = mm.collectMacros()
outDirs = []

for r in range(len(mm.regions)):
    mm.iterateRegion()

    scenario = mm.getScenario()
    flags = mm.collectFlags("flagsLimits")
    procs = " ".join(["-p " + b for b in mm.getProcs()])
    binnings = [mm.getVariable("bins", "")
Пример #10
0
                  "--final",
                  dest="final",
                  action="store_true",
                  default=False,
                  help="Only total yield")
parser.add_option("--fom",
                  dest="fom",
                  type="string",
                  default=None,
                  help="Figure of merit (S/B, S/sqrB, S/sqrSB)")

baseAll = "python mcAnalysis.py {MCA} {CUTS} -P {T} --neg --s2v --tree {TREENAME} {FINAL} {MCCS} {MACROS} -l {LUMI} {FRIENDS} {PROCS} {FLAGS} {FOM} >> {O}/{FILENAME}"
baseBin = "python mcPlots.py {MCA} {CUTS} {PLOTFILE} -P {T} --neg --s2v --tree {TREENAME} {FINAL} {MCCS} {MACROS} -l {LUMI} --pdir {O} {FRIENDS} {PROCS} {PLOTS} {FLAGS} --perBin --print txt"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm = maker.Maker("accmaker", baseAll, args, options)
if options.perBin: mm.reloadBase(baseBin)

friends = mm.collectFriends()
mccs = mm.collectMCCs()
macros = mm.collectMacros()
sl = str(options.lumi)

for r in range(len(mm.regions)):
    mm.iterateRegion()

    output = mm.outdir + "/" + scenario + "/accs" + sl.replace(
        ".", "p") + "/" + mm.region.name
    func.mkdir(output)

    scenario = mm.getScenario()
Пример #11
0
                  dest="models",
                  action="append",
                  default=[],
                  help="Fastsim signal models to loop upon.")
parser.add_option("--redoBkg",
                  dest="redoBkg",
                  action="store_true",
                  default=False,
                  help="Redo bkg if it already exists.")

baseBkg = "python makeShapeCardsSusy.py {MCA} {CUTS} \"{EXPR}\" \"{BINS}\" -o SR --bin {TAG} -P {T} --tree {TREENAME} {MCCS} {MACROS} --s2v -f -l {LUMI} --od {O} {FRIENDS} {FLAGS} {OVERFLOWCUTS}"
baseSig = "python makeShapeCardsSusy.py [[[MCA]]] {CUTS} \\\"{EXPR}\\\" \\\"{BINS}\\\" [[[SYS]]] -o SR --bin {TAG} -P {T} --tree {TREENAME} {MCCS} {MACROS} --s2v -f -l {LUMI} --od [[[O]]] {FRIENDS} {FLAGS} {OVERFLOWCUTS}"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
options.models = func.splitList(options.models)
mm = maker.Maker("scanmaker", baseBkg, args, options)
mm.loadModels()

friends = mm.collectFriends()
mccs = mm.collectMCCs()
macros = mm.collectMacros()
sl = str(options.lumi).replace(".", "p")

## first do bkg
if not options.sigOnly:

    mm.reloadBase(baseBkg)
    mm.resetRegion()

    ## looping over regions
    for r in range(len(mm.regions)):
Пример #12
0
from optparse import OptionParser
from lib import maker
from lib import functions as func

parser = OptionParser(usage="%prog cfg regions treedir outdir [options]")
parser = maker.addMakerOptions(parser)

base = "python mcDump.py --dumpFile .fdump.txt {MCA} {CUTS} {FMT} -P {T} --s2v --tree {TREENAME} -j 4 {MCCS} {MACROS} {FRIENDS} {PROCS} {FLAGS} &&  sort -n -k1 -k2 -k3 .fdump.txt > {O}/dump_{TAG}.txt && rm .fdump.txt"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm      = maker.Maker("dumpmaker", base, args, options)

friends  = mm.collectFriends()	
mccs     = mm.collectMCCs   ()
macros   = mm.collectMacros ()	

for r in range(len(mm.regions)):
	mm.iterateRegion()
	
	fmt = "'{run:1d} {lumi:9d} {evt:12d}\\t"+mm.getVariable("fmt","").replace("\\\\t","\\t")+"'"
	scenario = mm.getScenario   ()
	flags    = mm.collectFlags  ("flagDumps", False)
	procs    = mm.getProcs()

	for p in procs:
	
		output = mm.outdir +"/"+ scenario +"/dumps/"+ mm.region.name
		func.mkdir(output)
		
		tag = p.replace(".*.","").replace(".*", "").replace("*.","").rstrip("_")
		
Пример #13
0
    dest="lspam",
    type="string",
    default="Preliminary",
    help=
    "Left-spam for CMS_lumi in mcPlots, either Preliminary, Simulation, Internal or nothing"
)
parser.add_option("--noRatio",
                  dest="ratio",
                  action="store_false",
                  default=True,
                  help="Do NOT plot the ratio (i.e. give flag --showRatio)")

base = "python mcPlots.py {MCA} {CUTS} {PLOTFILE} -P {T} --neg --s2v --tree {TREENAME} -f --cmsprel '{LSPAM}' --legendWidth 0.20 --legendFontSize 0.035 {MCCS} {MACROS} {RATIO} -l {LUMI} --pdir {O} {FRIENDS} {PROCS} {PLOTS} {FLAGS} --showMCError"
(options, args) = parser.parse_args()
options = maker.splitLists(options)
mm = maker.Maker("plotmaker", base, args, options)

friends = mm.collectFriends()
mccs = mm.collectMCCs()
macros = mm.collectMacros()

for r in range(len(mm.regions)):
    mm.iterateRegion()

    flags = mm.collectFlags("flagsPlots")
    ratio = "--showRatio" if options.ratio else ""

    makes = collectMakes(mm.region, options.make)
    plots = collectPlots(mm.region, options.plots)
    scenario = mm.getScenario()